How to indicate open tabs in tree??

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: How to indicate open tabs in tree??

Post by klownboy »

Hi autocart, that's a nifty idea for segregating a script's perm to a separate scriptPV.dat file and then readPV'ing it later for use.

Just for jollies I set it up for a script I'll be sharing later (but not in that version). In this particular case, it doesn't make any sense because I was simply using the perm for a "1" or "0" status check on whether the Instant Color Filter was applied in a script. So I was using the same CTB or UDC or put the filter in place and also remove it if it was on. It made little sense because the filter can be toggle on and off by the toolbar button and not affect the saved perm variable. I checked out the thought process anyway and it did work fine. :) :appl:

Code: Select all

//*** Check perm variable $p_TabColors is set.  If set, toggle ON(1) or OFF(0)
   $TabColorsStatus = isset($p_TabColors)?$p_TabColors:"";
   if !($TabColorsStatus) {
      writePV "<xydata>\TempPV.dat";
      global $p_TabColors;
      $p_TabColors = "1";
      releaseglobals 2;
      perm $p_TabColors;
      writePV "<xydata>\TabColorScriptPerms.dat";
      readPV "<xydata>\TempPV.dat";
   }
   else {
      readPV "<xydata>\TabColorScriptPerms.dat";
      perm $p_TabColors;
      $p_TabColors = ($p_TabColors == "1")?"0":"1";
    }

// toggle Instant Color Filters "OFF" if "ON";
   if($p_TabColors) {#1077; end 1;}
   else {continue script...}
*/
Since you're generating a separate file to accomplish this, it probably makes more sense to simply use an INI file to store the variables and use SC getkey and setkey. If you want to avoid the separate INI file, you can even include the INI section in the script itself like this. The INI section can even be commented out and getkey setkey will still work.

Code: Select all

/* ###   INI Settings - Do not tamper with or remove   ###
[INI]
CTBindex=42
*/
Using SC setkey and getkey as follows:

Code: Select all

 setkey "$ctbindex", "CTBindex", "INI", self("file");
 $ctbindex = getkey("CTBindex", "INI", self("file"));
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

autocart
Posts: 1246
Joined: 26 Sep 2013 15:22

Re: How to indicate open tabs in tree??

Post by autocart »

klownboy wrote: 20 Oct 2021 17:31 Since you're generating a separate file to accomplish this, it probably makes more sense to simply use an INI file to store the variables and use SC getkey and setkey. If you want to avoid the separate INI file, you can even include the INI section in the script itself like this. The INI section can even be commented out and getkey setkey will still work.
That is true. And all the script's perms must be collected manually anyway. And the ini approach would also not mess with the other "foreign" perms.
Thx. I also like the ini section inside the script file itself. Cool solution. Thank you for still testing my idea about segregating a perms selection into a separate pv file.

EDIT:
The only case where it might make sense to create a pv file like that instead of an ini, was maybe if one had a lot of perms to read. I assume - untested - that reading many perms in a row from a pv file would be faster than reading many keys from an ini file?

klownboy
Posts: 4109
Joined: 28 Feb 2012 19:27

Re: How to indicate open tabs in tree??

Post by klownboy »

autocart wrote: 20 Oct 2021 17:56 I also like the ini section inside the script file itself. Cool solution
I did like your thought process for using the separate scriptPV.dat file so I figured I try it out. I can't take credit for the - INI section included within the script itself - idea. I think I saw it first in a FluxTorpedoe script. Though it wasn't Session Manager, that uses a separate ini file. I thought it was pretty cool too and told Flux that. So I've used it a number of times since.

As far as speed on using SC keykey and setkey in a separate ini file or within the script itself, it is extremely fast. I ran some speed test a couple of years ago on INI section within the script with about 10 items to store and it was so fast it barely registered anything.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Post Reply