Page 1 of 2
Help file - small improvements...
Posted: 21 Dec 2011 13:29
by Borut
inputfolder()
First example - explanation should read (I suppose):
"Asks the user to select a folder (starting the dialog in C:\) and puts its full name in variable $folder. Then copies the folder name to clipboard."
The intention is clear. This is just an improvement possibility. BTW, congratulations once more for 10.70!
Re: Help file - small improvements...
Posted: 21 Dec 2011 13:49
by admin
Correct, thanks!
Re: Help file - small improvements...
Posted: 25 Dec 2011 00:21
by Borut
Scripting Commands Reference | load | Examples
Either all "goto.xys" should be replaced with "goto.txt" (preferably), or all "Goto.txt" should be replaced with "goto.xys".
Scripting Commands Reference | If/ElseIf/Else Blocks
If expression evaluates to TRUE, the following statement block is executed and the other blocks are ignored.
Re: Help file - small improvements...
Posted: 03 Jan 2012 11:38
by admin
Thanks!
Re: Help file - small improvements...
Posted: 11 Jan 2012 12:36
by Borut
Scripting | Variables | Interpolation
I am really not sure about this one - it may very well be that everything is ok and I am misunderstanding the issue... Help says:
Interpolation means that variables that are embedded in double-quoted or unquoted strings are resolved (replaced with their corresponding value).[...]Interpolating XYplorer internal variables...To avoid ambiguities in parsing, you have to put XY internal variables (<curpath>, <xyver>...) within doubled quotes strings IF they are to be interpolated! Otherwise the < or > character might be interpreted as being the operator within a comparison.
msg XY path = <xypath>; // will not work as expected!
msg "XY path = <xypath>"; // okay
msg "XY path = " . "<xypath>"; // okay (not interpolated)
If I try each of these three lines in the address bar (of course preceded with ::), it seems that <xypath> is being evaluated each time. If I try
then it is not evaluated (as expected, I would say).
Re: Help file - small improvements...
Posted: 11 Jan 2012 20:03
by admin
Borut wrote:Scripting | Variables | Interpolation
I am really not sure about this one - it may very well be that everything is ok and I am misunderstanding the issue... Help says:
Interpolation means that variables that are embedded in double-quoted or unquoted strings are resolved (replaced with their corresponding value).[...]Interpolating XYplorer internal variables...To avoid ambiguities in parsing, you have to put XY internal variables (<curpath>, <xyver>...) within doubled quotes strings IF they are to be interpolated! Otherwise the < or > character might be interpreted as being the operator within a comparison.
msg XY path = <xypath>; // will not work as expected!
msg "XY path = <xypath>"; // okay
msg "XY path = " . "<xypath>"; // okay (not interpolated)
If I try each of these three lines in the address bar (of course preceded with ::), it seems that <xypath> is being evaluated each time. If I try
then it is not evaluated (as expected, I would say).
You are right. Part of it is outdated, part of it is nonsense, part of it is ok. Thanks!
Re: Help file - small improvements...
Posted: 14 Jan 2012 13:31
by Borut
Scripting | Variables
Here I am again not sure if I am misunderstanding something, or my SC experiments bring me to wrong conclusions, or there is perhaps really a need for some additional clarification... Help says:
Variables that are not set to any value are not resolved, but displayed
My question: Is it so also for permanent (and global) variables? After experimenting a bit, I would say that a permanent variable (after the perm command) has something like a value nil afterwards, i.e. when compared with a string, it seems it has a value "" (empty string). Are my observations correct? If so, maybe this should be written somewhere explicitly (or I was not able to find it).
Re: Help file - small improvements...
Posted: 14 Jan 2012 13:39
by admin
You have example code?
Re: Help file - small improvements...
Posted: 14 Jan 2012 13:58
by Borut
admin wrote:You have example code?
Code: Select all
"Case 1"
releaseglobals;
perm $p_TabsetBase;
$p_TabsetBase=($p_TabsetBase=='$p_TabsetBase') ? '<xydata>\Panes' : "NO CHANGE";
msg "$p_TabsetBase";
"Case 2"
releaseglobals;
perm $p_TabsetBase;
$p_TabsetBase=($p_TabsetBase=="") ? '<xydata>\Panes' : "NO CHANGE";
msg "$p_TabsetBase";
Re: Help file - small improvements...
Posted: 14 Jan 2012 14:35
by admin
Hm, don't know what you mean. Here's unsetting a perm var and I don't see any problems:
Code: Select all
"unsetting a perm var"
perm $p_TabsetBase;
$p_TabsetBase = "test";
msg $p_TabsetBase;
unset $p_TabsetBase;
msg $p_TabsetBase;
Re: Help file - small improvements...
Posted: 14 Jan 2012 14:54
by Borut
Yes, yes, in your example everything seems OK. BUT, try this:
Code: Select all
"perm var initial state"
perm $p_TabsetBase;
msg $p_TabsetBase;
Namely, I need to detect if a value of a permanent global variable has ever been defined or not. I was expecting to receive $p_TabsetBase in the message of this example, but I am apparently receiving an empty string.
Re: Help file - small improvements...
Posted: 14 Jan 2012 14:57
by admin
Borut wrote:Yes, yes, in your example everything seems OK. BUT, try this:
Code: Select all
"perm var initial state"
perm $p_TabsetBase;
msg $p_TabsetBase;
Namely, I need to detect if a value of a permanent global variable has ever been defined or not. I was expecting to receive $p_TabsetBase in the message of this example, but I am apparently receiving an empty string.
Ah. The perm command initializes the variable to "". I will add it to Help.
Re: Help file - small improvements...
Posted: 14 Jan 2012 15:10
by Borut
admin wrote:Ah. The perm command initializes the variable to "". I will add it to Help.
But, upon further thinking, although for my purposes I can check after "", it seems that it is actually an inconsistency of the scripting engine. Maybe it would be better to change this behavior (if possible).
Re: Help file - small improvements...
Posted: 14 Jan 2012 16:52
by PeterH
Variables that are not set to any value are not resolved, but displayed
Doesn't this mean, in other words, that it's an
undefined variable?
While a non-filled variable defined as global is not undefined?
As much as I remember from other scripting languages they do the same as XY.
And I think I remember that XY documents this way to handle it somewhere...
By the way: after
Code: Select all
perm $p_TabsetBase;
$p_TabsetBase = '$p_TabsetBase'
Do you think this var is "not defined" or "not initialized" - what ever this means?
Re: Help file - small improvements...
Posted: 14 Jan 2012 23:08
by Borut
PeterH, if you are directing these questions to me, then I would say: It is all a question of definition.
I do not use other scripting languages, so I do not know how they are handling perm variables. I was not able to find the relevant description in the on-line help (if there already is one about "", then it should perhaps be made more visible (what Don is going to do)), and I have learned the hard way that the one about regular variables does not apply to perm variables. However, I do not see the reason for different treatment. Regarding your code snippet:
Code: Select all
perm $p_TabsetBase;
$p_TabsetBase = '$p_TabsetBase'
- it is exactly what I would expect that the scripting engine does, when interpreting a perm command for a variable which is not already in the internal list of permed variables (currently it obviously does this for the regular variables, upon the first occurrence (implicit declaration)).
But, as I said,
my scripts now work happily with "" as initial values of perm variables, so my suggestion about changing the scripting engine was just that - a suggestion.