Permanent Variables: "Rememberance" needs two cycles to work

Things you’d like to miss in the future...
Forum rules
You might want to read this if you're looking for priority service

:info: Please Include The Following Information
1) Your XYplorer Version (e.g., v28.00.0801)
2) Your Windows Version (e.g., Win 11)
3) Your Screen Scaling Percentage (e.g., 125%).

:info: Use Your Profile Or Signature
We strongly recommend adding your Windows Version and Screen Scaling Percentage to the Location field in your Profile or to your Signature. That way, you only have to type them once, and we won't have to search for that vital information.

:info: How To Attach Images
When attaching an Image, please use the Attachment tab at the bottom of your post and click "Add files".
Post Reply
Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Permanent Variables: "Rememberance" needs two cycles to work

Post 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

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

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

Post 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;

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

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

Post 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

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

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

Post by admin »

Frankly, I was surprised myself and had to look up the Help to see why your code did not work. :)

yusef88
Posts: 1148
Joined: 28 Jan 2013 03:50
Location: Windows 8.1 32-bit

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

Post 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

Filehero
Posts: 2734
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

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

Post 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

PeterH
Posts: 2830
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

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

Post 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.

Post Reply