Page 1 of 1

Permanent Variables: "Rememberance" needs two cycles to work

Posted: 02 Mar 2012 20:58
by Filehero
Hi,

observation
making a permanent variable remembered (HD-persistent) at least needs two cycles of setting/restarting XY to become effective.

env
; XYplorer 10.90.0000 configuration file
; Windows 7 Professional (Service Pack 1), 64-bit


test script

Code: Select all

"Create test variable"
  $p_myName = "Filehero";
  perm $p_myName;
  
"Check test variable"
  msg $p_myName;
reproduction
1. Take any running XY session.
2. From the menu bar open Scripting/Run script... and paste the test script.
3. Run the "Create test variable" script from the script popup.
4. From the menu open Scripting/Permanent Variables . -> the popup lists en entry "$p_myName = "
5. Close and restart XY.
6. From the menu bar open Scripting/Permanent Variables . -> the popup lists en entry "$p_myName = " :arrow: Gotcha!
7. Run the "Create test variable" script from the script popup again.
8. From the menu open Scripting/Permanent Variables . -> the popup lists en entry "$p_myName = Filehero" :arrow: Approved!


Cheers,
Filehero

Re: Permanent Variables: "Rememberance" needs two cycles to

Posted: 02 Mar 2012 21:08
by admin
Help:
If a variable did not exist before the perm command initializes it to "" (empty string).
Therefore you should put the perm statement first, and your script should look like this:

Code: Select all

"Create test variable"
  perm $p_myName;
  $p_myName = "Filehero";
 
"Check test variable"
  msg $p_myName;

Re: Permanent Variables: "Rememberance" needs two cycles to

Posted: 03 Mar 2012 11:43
by Filehero
Hi,

thanks for clarification.

Of course, I did read the help section before - but forgot to take a deeper look into the scope section. :oops:
Got it now: my first one was a local var, and local vars could never become permanent by definition.


Cheers,
Filehero

Re: Permanent Variables: "Rememberance" needs two cycles to

Posted: 03 Mar 2012 11:56
by admin
Frankly, I was surprised myself and had to look up the Help to see why your code did not work. :)

Re: Permanent Variables: "Rememberance" needs two cycles to

Posted: 19 Jul 2014 20:52
by yusef88
admin wrote:Help:
If a variable did not exist before the perm command initializes it to "" (empty string).
Therefore you should put the perm statement first, and your script should look like this:

Code: Select all

"Create test variable"
  perm $p_myName;
  $p_myName = "Filehero";
 
"Check test variable"
  msg $p_myName;
what's the benefit Permanent Variables,can i open files through it? "Filehero\1.doxc" for an example

Re: Permanent Variables: "Rememberance" needs two cycles to

Posted: 19 Jul 2014 22:46
by Filehero
yusef88 wrote:what's the benefit Permanent Variables,can i open files through it? "Filehero\1.doxc" for an example
Your question is sort of special. :whistle:

In brief, PVs share the basic principle with normal variables and add persistence so that they survive a XY session. That means, in general you can do everything you can do with XY script variables, Of course, this includes e.g. opening a file. But for the latter PVs are plain overkill (because you could simply double-click the file, or you can add it to the file favorites and open it from there and so on).


Cheers,
Filehero

Re: Permanent Variables: "Rememberance" needs two cycles to

Posted: 21 Jul 2014 22:01
by PeterH
Just a little correction here...

Perm variables can be shared between independant scripts, i.e. one script can store some value, later scripts can refer (or change) it.

You *can* save and restore Perm variables to survive even XY restart.