Perm variable issue?

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

Perm variable issue?

Post by klownboy »

Is there an issue with establishing a variable permanent (relatively long one) or am I losing my mind. Running these commands seems to be very inconsistent at least for me, in that at least 50% of the time the variable is not established as permanent.

Code: Select all

::#552; $labels = report("{Name}|"); echo $labels; perm $labels;
I check in the Menu bar |Scripting | Permanent Variables for permanent variables assigned after running it in the AB and half of the time the variable was not established as permanent. Of course after running it each time (it was set as perm) I'd unset the perm variable. I was running something similar using a load command script label and I was wondering why it wasn't working so I simply put it in the AB to test and low and behold sometimes it worked and sometimes it didn't. It seems very odd. Am I doing something not so bright or can anyone figure out why the variable is not established as permanent 50% of the time? Thanks for any help.
Ken

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

Re: Perm variable issue?

Post by admin »

Wrong sequence. Do like this:

Code: Select all

::#552;  perm $labels; $labels = report("{Name}|"); echo $labels;
or cooler:

Code: Select all

::#552;  perm $labels = report("{Name}|"); echo $labels;

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

Re: Perm variable issue?

Post by klownboy »

Thanks Don, I knew about combining the perm with the establishment of the variable and have done it many times, but I lost track of setting perm up front as being the right way. And by the way, I can stop doodling with this since you've come out with v13.30.0009 and <get drivename "C:">. Great addition to scripting. It will be quite handy to determine a flash drives existence by "name" or assigning a drive's name to a tab.
Thanks,
Ken

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

Re: Perm variable issue?

Post by admin »

Just curious: Wouldn't you rather like "TheDriveName" instead of "(C:) TheDriveName" to be returned?

highend
Posts: 14954
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Perm variable issue?

Post by highend »

Wouldn't you rather like "TheDriveName" instead of "(C:) TheDriveName" to be returned?
Absolutely but I though: If I ask for it in my wishes thread you'd argue: No, I'm relying on the windows api and
that just returns everything but not only the drive name... ;)
One of my scripts helped you out? Please donate via Paypal

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

Re: Perm variable issue?

Post by klownboy »

Don, your suggestion may save a couple of lines in scripting if/when you only want the Volume Name and not the associated Drive letter. We have to strip out the drive business to obtain just the Volume Name. Though maybe you should get other opinions since there may situations where someone would like both. By the way for me, the results display as "Transcend (C:)" not "(C:) Transcend" if it matters.

Code: Select all

    $Rem_Dr = get("drives", 2), "|");
    $Dr_Cnt = gettoken($Rem_Dr, "count", "|");
      end $Dr_Cnt < "1", "You have no removable drives on-line, aborting!";
    if ($Dr_Cnt > "1") {
      status "You have more than one flash or external hard drive on-line!"; }     // Edit: the closing "}" was inadvertently left out
      foreach($root, $Rem_Dr, "|") {
       $drive_name = get("drivename", $root, 1);
             $drive_label = trim(gettoken($drive_name, 1, " ("));
             $drive = trim(gettoken($drive_name, 2, " ("), ")");
             echo $drive_label . " is Drive " . $drive; }
It looks like you have another opinion already...highend agrees.
Thanks,
Ken
Last edited by klownboy on 19 Nov 2013 20:03, edited 2 times in total.

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

Re: Perm variable issue?

Post by klownboy »

"Drive name" or "drive name and letter", that was quick! Now it's even better.

Post Reply