Page 1 of 1
Help With little script
Posted: 08 Aug 2015 15:45
by DB06
Hi, i want to create simple button that switches between 2 catalogs (If, x catalog is opened - open y, else open x). But i can't find function that would retrieve name of currently opened catalog. Is this possible, to archive in other way? Thanks for help!

Re: Help With little script
Posted: 08 Aug 2015 15:57
by highend
You could use catalogreport() to get a report on all items in the current catalog. Then check if this list contains a specific item that is not present in your current catalog -> Load the second one. Vice versa with the second catalog...
Re: Help With little script
Posted: 08 Aug 2015 16:01
by DB06
Thanks for suggestion, will try out.

Re: Help With little script
Posted: 08 Aug 2015 16:12
by DB06
If it's not too hard, could you post sample script for this? I'm not programmer and have no experience with Xyplorer scripting. Thanks.

Re: Help With little script
Posted: 08 Aug 2015 22:29
by klownboy
Here's a simple example script where I'm looking for a unique word in the caption of my "Normal" catalog. If the script finds the word "Solsuite" in the captions of the catalog, it loads another catalog named "Rating". If it doesn't find that word, it loads my "Normal" catalog. Obviously you'd have to change that key word and the names of your catalogs you'd like to load.
Code: Select all
$cat_list = catalogreport("{Caption}","{Caption}");
if (formatlist($cat_list, "tf", "<crlf>", "Solsuite") LikeI "Solsuite") { //in this case, I'm searching in my "Normal" catalog for some unique word in the captions, "Solsuite"
catalogload "Rating.dat"; } //if Solsuite is found it loads my "Rating" catalog
else {
catalogload "Normal.dat"; } //if Solsuite is not found it loads my "Normal" catalog
Good luck and welcome to the XY forum. Highend may come up with a slicker method. So many ways to get the same thing accomplished in XYplorer.

You could assign the script to a Customized Keyboard Shortcut, a CTB, or even an item in the 2 catalogs.
Ken
Re: Help With little script
Posted: 09 Aug 2015 07:21
by highend
I would have used
Code: Select all
if (regexmatches($cat_list, "Solsuite")) {
but apart from that the code would have been the same

Re: Help With little script
Posted: 09 Aug 2015 17:29
by klownboy
Thanks highend for the regexmatches version. I was thinking about regexmatches but wasn't sure if I could get it right...should have tried it especially since it was a simple example. Not a bad way to quickly toggle between 2 catalogs.