Page 1 of 1

Lost Perm variables

Posted: 03 Jan 2013 15:59
by PeterH
This seems to be a very strange one :shock:

Code: Select all

// Script Docu: Test "Perm" problem with Global

"Set 2 Perm Vars"
// -------------------------------------------------------------------------------------------------
 Global  $names;
// -------------------------------------------------------------------------------------------------
   Msg "Before 'Perm': _PV = $_PV";

 Perm $_PV;
   $_PV = "eins";

   Msg "After 'Perm' & 'Set': _PV = $_PV";
Execute this script (a shortened extract of a real script) - it just defines $_PV as Perm and assigns a value.
When ended: test by Scripting/Permanent Variables :arrow: all seems OK!

But: if you now start any script (do it in stepping mode) this new Global Variable suddenly is completely lost, as if Unset was executed.
(With Step mode you can show it before the first command is executed.)

If in this script you delete the "Global $names" statement, everything will be OK!

Re: Lost Perm variables

Posted: 03 Jan 2013 16:16
by admin
Sure? All fine here.

Re: Lost Perm variables

Posted: 03 Jan 2013 17:09
by PeterH
admin wrote:Sure? All fine here.
Yes, sure :cry:

To verify:
- I just restarted XY :arrow: not one Perm to find
- copy/pasted above code to Try Script...
- executed all :arrow: after that the variable was known as perm
- started Try Script... a second time
- before execution of "Global" there was not any var to be shown (No Variables... button!) :(
- after 1*Continue (= execution of Global) *only* the global, not the perm was shown
- after 2nd Continue the 1st "Msg" showed the *undefined* perm variable

So here it happens with a real scriptfile, and it happens with try script.

By the way: in the tests before some perms existed before the test. They were *not* affected by this script - only perms (I also did it with 2 perms) defined as new in this script were affected!
If I delete the Global and run the script, the perm variable(s) remain(s) defined. If I then re-add the global everything seems OK - the perm stays permanent :roll:

What i said: strange!

Re: Lost Perm variables

Posted: 03 Jan 2013 17:16
by PeterH
And one more...

copied XYplorer.exe + XYcopy.exe to new directory, then retried above "Try Script..."

:arrow: same problem :cry:

Re: Lost Perm variables

Posted: 03 Jan 2013 17:16
by admin
You said:
PeterH wrote:But: if you now start any script (do it in stepping mode) this new Global Variable suddenly is completely lost, as if Unset was executed.
That is what I tested.

But now you run the same script again. So is this the bug condition? Run exactly this script two times?

Re: Lost Perm variables

Posted: 03 Jan 2013 17:19
by PeterH
admin wrote:You said:
PeterH wrote:But: if you now start any script (do it in stepping mode) this new Global Variable suddenly is completely lost, as if Unset was executed.
That is what I tested.

But now you run the same script again. So is this the bug condition? Run exactly this script two times?
No no no - no difference with same *or* any other script! Error in both situations, even before 1st instruction executed!

Re: Lost Perm variables

Posted: 03 Jan 2013 17:20
by admin
Can anybody repro this?

Re: Lost Perm variables

Posted: 03 Jan 2013 17:43
by PeterH
Above tests all were on W7(X64) SP1.

Now retested on my normal XY on WXP SP3 in Virtual Box. Same problem.

To say again - maybe the strangest thing of all: after having executed the script, the permanent var can be seen by Scripting/Permanent Variables.
Just by starting any script then (same or other), before executing any command of the script, the new permanent var disappears.


("Har har har" he chortled. "I'll take your treasure and take it away."
And then he disappeared into the gloom...)
Just OT, from a 30+ year old adventure game on a mainframe :lol:


PS - is there any problem with http://www.xyplorer.com? since about 1 hour I very often can't reach it, while other sites have no problems.

Re: Lost Perm variables

Posted: 03 Jan 2013 17:54
by Marco
I can repro running the script in the OP twice.
Weird...

Re: Lost Perm variables

Posted: 03 Jan 2013 18:09
by admin
WOW, I got it. This (rare) bug is there since we have permanent variables. Thanks, PeterH! Fix comes.

Re: Lost Perm variables

Posted: 03 Jan 2013 19:51
by PeterH
admin wrote:WOW, I got it. This (rare) bug is there since we have permanent variables. Thanks, PeterH! Fix comes.
Good to hear - thanks :appl:

Re: Lost Perm variables

Posted: 05 Jan 2013 22:24
by PeterH
admin wrote:WOW, I got it. This (rare) bug is there since we have permanent variables. Thanks, PeterH! Fix comes.
Tested 11.90.0104.

Neither above example nor any of my other (rare :P ) tests continue to show the error.

So I now can start working heavily :lol: with global variables. Thanks a lot!


PS
I missed completely the advantage of permanent variables to be automatically used in every script, after having been defined once! Having noticed this some days ago started me re-using them, e.g. as simulated parameters to "simulated subroutines or functions". This sometimes *can* be more easy than using globals, that must be defined everywhere. (Though you must be very careful with the names of perms :ugeek: )
(Much better would be the ability to use scripts as *real* functions or subroutines, but I've said/asked that some times before :roll: )