Page 1 of 1
[Solved] SC Exists and "paper:" syntax
Posted: 05 Dec 2014 21:35
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.
Re: SC Exists and "paper:" syntax
Posted: 06 Dec 2014 03:24
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.
Re: SC Exists and "paper:" syntax
Posted: 06 Dec 2014 09:22
by admin
Yes. "<xypaper>\Wallpaper\Maine.txt" is the way to go.
Re: SC Exists and "paper:" syntax
Posted: 06 Dec 2014 12:31
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.
Re: [Solved] SC Exists and "paper:" syntax
Posted: 06 Dec 2014 13:03
by admin
OK, you are right. I add it to exists().
Re: [Solved] SC Exists and "paper:" syntax
Posted: 06 Dec 2014 13:41
by klownboy
Thanks Don, but don't bother if it's too much work. I can always check the existence of the txt file.
Re: [Solved] SC Exists and "paper:" syntax
Posted: 06 Dec 2014 13:47
by admin
No problem, easy.
Re: [Solved] SC Exists and "paper:" syntax
Posted: 06 Dec 2014 16:35
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.
Re: [Solved] SC Exists and "paper:" syntax
Posted: 08 Dec 2014 19:48
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:
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.
Re: [Solved] SC Exists and "paper:" syntax
Posted: 09 Dec 2014 14:44
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.