[Solved] SC Exists and "paper:" syntax

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

[Solved] SC Exists and "paper:" syntax

Post by klownboy »

In my testing, it does not appear that SC exists works with the paper syntax of "paper:\Wallpaper\Maine". For example, this doesn't work, with or without quotes, whether the paper txt file is located in the Paper folder or a sub folder, or whether you use the txt extension:

Code: Select all

::if !(exists("paper:Wallpaper\Maine"))) {text "not exist";}
Whereas, obviously this works fine.

Code: Select all

::if !(exists("<xypaper>\Wallpaper\Maine.txt")) {text "not exist";}
Not a huge deal in any shape or form. I was wondering if it should work or should we use the second example (<xypaper>\...) to check the existence of the paper folder (i.e., the actual text file)? Thanks.
Last edited by klownboy on 06 Dec 2014 12:35, edited 1 time in total.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: SC Exists and "paper:" syntax

Post by bdeshi »

Actually makes some kind of sense since exists() only "checks whether a file or directory or URL exists." and paper: paths are not really a directory.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

admin
Site Admin
Posts: 66323
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: SC Exists and "paper:" syntax

Post by admin »

Yes. "<xypaper>\Wallpaper\Maine.txt" is the way to go.

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: SC Exists and "paper:" syntax

Post by klownboy »

Thanks, no problem either way. I asked only because the hash for thumbnail cache file(s) is based on "paper:Wallpaper\Maine*240x240" so internally XY is treating that as a folder as far as thumbnails cache(s) are concerned.

admin
Site Admin
Posts: 66323
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: [Solved] SC Exists and "paper:" syntax

Post by admin »

OK, you are right. I add it to exists().

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: [Solved] SC Exists and "paper:" syntax

Post by klownboy »

Thanks Don, but don't bother if it's too much work. I can always check the existence of the txt file.

admin
Site Admin
Posts: 66323
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: [Solved] SC Exists and "paper:" syntax

Post by admin »

No problem, easy.

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: [Solved] SC Exists and "paper:" syntax

Post by klownboy »

V14.60.0208 did make it easier in scripting to determine if the "folder" the thumbnail cache pointed to existed, in that I didn't have to break it to determine if it was a paper type folder. Thanks Don.

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: [Solved] SC Exists and "paper:" syntax

Post by TheQwerty »

FYI...

Without knowing your full script I'm not sure this will be useful.

I had a couple scripts which needed to use the 'r' and 'd' flags before adding items to a PF, but unfortunately if the PF didn't exist before calling those it would show an annoying error dialog.

Rather than take care of all the possible cases with a non-paper-folder supporting Exists, I simply started the scripts with an empty append:

Code: Select all

PaperFolder($G_NAME,,, 'a');
This ensures that the file exists and though the calls to 'r' and 'd' are still redundant in this case they no longer throw error dialogs.

klownboy
Posts: 4462
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: [Solved] SC Exists and "paper:" syntax

Post by klownboy »

Thanks TheQwerty, I will keep that in mind. For the script modification I'm working on, I'm using data extracted directly from the thumbnail cache dat2 file which specifies the paperfolder as "paper:Wallpaper\Ireland*240x240" so Don's "exists" change did help, in that all I had to do was extract the "paper: Wallpaper\Ireland" and determine if it still existed. Which was much easier than what I did before. I was converting the paper to the actual "txt " file...

Code: Select all

  $paperfolder = "paper:Wallpaper\Ireland*240x240*c1a01c8bfdfbde00ec50d1e88f23e8e5";
  $paperfolder = gettoken(gettoken($paperfolder, 1,"*"), 2, ":") . ".txt";
  if (exists("<xypaper>\$paperfolder")) {...}
Though I hadn't looked at SC paperfolder to see if there would have been a simpler way "before" Don "exists" change. If I use SC "paperfolder" on a non-existing paperfolder, I get a "system can not find the specified file" error message which is understandable. For scripting purposes, instead of getting that error, maybe it would have been better if Don had returned an error code without the message. You could then use something like, "$p =paperfolder("Wallpaper\Ireland", , , "r") and if it returned a that error code, the paperfolder doesn't exist. Thanks again.

Post Reply