Help With little script
-
DB06
- Posts: 13
- Joined: 08 Aug 2015 15:42
Help With little script
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! 
-
highend
- Posts: 14940
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Help With little script
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...
One of my scripts helped you out? Please donate via Paypal
-
DB06
- Posts: 13
- Joined: 08 Aug 2015 15:42
Re: Help With little script
Thanks for suggestion, will try out. 
-
DB06
- Posts: 13
- Joined: 08 Aug 2015 15:42
Re: Help With little script
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. 
-
klownboy
- Posts: 4459
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8037 at 100% 2560x1440
Re: Help With little script
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. 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
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
Ken
-
highend
- Posts: 14940
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Help With little script
I would have used
but apart from that the code would have been the same 
Code: Select all
if (regexmatches($cat_list, "Solsuite")) {One of my scripts helped you out? Please donate via Paypal
-
klownboy
- Posts: 4459
- Joined: 28 Feb 2012 19:27
- Location: Windows 11, 25H2 Build 26200.8037 at 100% 2560x1440
Re: Help With little script
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.
XYplorer Beta Club