change variable with step
change variable with step
Hello !
I am trying to write some scripts in xyplorer and when I use "Try Script" option and see mistakes. But I cannot fix variables by editing in "Variables On Stack" . I hope xyplorer has this ability. Thank you! 
s404:signature not found.
Re: change variable with step
No, you can't change any variables during the debugging processI hope xyplorer has this ability
One of my scripts helped you out? Please donate via Paypal
Re: change variable with step
You actually can change global and permanent variables while the stepping dialog is active but the new value will not be used in the command that is currently being stepped.
While the stepping dialog is waiting on you start XY again but use the /script parameter to change the value:The first echo will still show 'hello', but the second will show 'blah'.
I wouldn't recommend actually using this or relying on this to not change though.
Code: Select all
::global $a = 'hello';step;echo $a;echo $a;Code: Select all
XYplorer.exe /script="::global $a='blah';"I wouldn't recommend actually using this or relying on this to not change though.
Re: change variable with step
But I see little trouble in very large script. And if changing a variable this time allows me to keep running this script. Other wise I have to again start at the beginnning again. ?
s404:signature not found.
Re: change variable with step
Thank to TheQwerty. I did not see your text. I will try your advise.
s404:signature not found.
Re: change variable with step
Thank you. But still I cannot edit un-global variables.TheQwerty wrote:You actually can change global and permanent variables while the stepping dialog is active but the new value will not be used in the command that is currently being stepped.
While the stepping dialog is waiting on you start XY again but use the /script parameter to change the value:Code: Select all
::global $a = 'hello';step;echo $a;echo $a;The first echo will still show 'hello', but the second will show 'blah'.Code: Select all
XYplorer.exe /script="::global $a='blah';"
I wouldn't recommend actually using this or relying on this to not change though.
s404:signature not found.
Re: change variable with step
XY is not an IDE and debugging is limited to step or a "?" in front of a command. Global variables and permanent ones have their purpose but polluting the current scope with them is not what I'd call "good practice".
Don't forget that you can unstep; as well, so you normally only debug a smaller part of your script by surrounding that part with step / unstep and you can always spit out values to check if something is working correctly or not (either by writing a log or using the script command status if you don't want to be bothered with a gui output that requires user interaction).
Don't forget that you can unstep; as well, so you normally only debug a smaller part of your script by surrounding that part with step / unstep and you can always spit out values to check if something is working correctly or not (either by writing a log or using the script command status if you don't want to be bothered with a gui output that requires user interaction).
One of my scripts helped you out? Please donate via Paypal
Re: change variable with step
You can always insert temporary Inputs to make this possible - even bundling it up in a function if desired, though it does add cruft to the "release" version:
Code: Select all
function DEBUG($name, &$v) {
if (true) {
$v = Input('Debugger',"Modifying $name", $v, 'm');
}
}
"Main"
$v = 'hello';
DEBUG('$v', $v);
echo $v;Re: change variable with step
@TheQwerty
OT: Gz for your 4k post! (actually I'm 2 posts too late^^)
OT: Gz for your 4k post! (actually I'm 2 posts too late^^)
One of my scripts helped you out? Please donate via Paypal
-
PeterH
- Posts: 2826
- Joined: 21 Nov 2005 20:39
- Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%
Re: change variable with step
Hm - do I see it right?TheQwerty wrote:You can always insert temporary Inputs to make this possible - even bundling it up in a function if desired, though it does add cruft to the "release" version:Code: Select all
function DEBUG($name, &$v) { if (true) { $v = Input('Debugger',"Modifying $name", $v, 'm'); } } "Main" $v = 'hello'; DEBUG('$v', $v); echo $v;
If yes, then you have to add the DEBUG-line after each line of code setting a variable.
OK: if you happen to know the line you made a mistake in ...
(Name it "planned mistake"
To ease up a release version, you can expand:
Code: Select all
function DEBUG($name, &$v) {
if (true) {
$v = Input('Debugger',"Modifying $name", $v, 'm');
}
}
"Main"
$debug = true; // debugging active
$v = 'hello';
If ($debug) { DEBUG('$v', $v); }
echo $v;
(I sometimes really use that to (not) output debug messages
Re: change variable with step
Yes... it's intended for localized debugging. It's not so much that you need to know where the mistake is, but where there's no turning back with that particular variable/value.PeterH wrote:Hm - do I see it right?
If yes, then you have to add the DEBUG-line after each line of code setting a variable.
OK: if you happen to know the line you made a mistake in ...![]()
This entire thread is things which are not recommended.
Not needed, just change the true in DEBUG to false. It will still be stepped through but nothing will occur within the function - same as your variable, but with the benefit you're not worrying about keeping that variable in scope.PeterH wrote:To ease up a release version, you can expand. . . For release version change $debug to false.
But again none of this is actually recommended for long-term use.
Re: change variable with step
What's the purpose of this if-clause?TheQwerty wrote:Code: Select all
function DEBUG($name, &$v) { if (true) { --^^^^^^^^ $v = Input('Debugger',"Modifying $name", $v, 'm'); } }
Re: change variable with step
so that you can later replace it with false, and all debug prompts will die.
Code: Select all
function DEBUG($name, &$v) {
if (false) {
--^^^^^^^^^
$v = Input('Debugger',"Modifying $name", $v, 'm');
}
}Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
Re: change variable with step
Thanks, so I supposed right. I think, I would define a perm var switch for that.
@TheQwerty: good idea!
@TheQwerty: good idea!
SammaySarkar wrote:so that you can later replace it with false, and all debug prompts will die.
XYplorer Beta Club