Page 1 of 1

Perm variable issue?

Posted: 18 Nov 2013 14:45
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

Re: Perm variable issue?

Posted: 18 Nov 2013 15:14
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;

Re: Perm variable issue?

Posted: 18 Nov 2013 15:38
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

Re: Perm variable issue?

Posted: 18 Nov 2013 15:40
by admin
Just curious: Wouldn't you rather like "TheDriveName" instead of "(C:) TheDriveName" to be returned?

Re: Perm variable issue?

Posted: 18 Nov 2013 15:50
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... ;)

Re: Perm variable issue?

Posted: 18 Nov 2013 15:55
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

Re: Perm variable issue?

Posted: 18 Nov 2013 17:27
by klownboy
"Drive name" or "drive name and letter", that was quick! Now it's even better.