Legal Variables in Scripting

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
admin
Site Admin
Posts: 66257
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Legal Variables in Scripting

Post by admin »

PeterH wrote:
admin wrote:I would not recommend it but currently this works:

Code: Select all

::set $getInfo, "file"; msg "This is ". $getInfo(file);
$getInfo(file) is an unquoted string where $getInfo is interpolated. Without the $ it would be ambiguous with a function getInfo().
Sorry: I don't understand this code at all. Maybe there's an error in it?
($getInfo is setted to "file"??)

What I wanted to say: a name followed by "(" is (from my point of view, or from REXX...?) a function, not a variable. So if you recognize a name as a function name, you should not interpret it as variable name.
With this, your 2nd statement would expand to call the function $getInfo with parm file - where file is an (undefined?) variable?
The example was constructed to show the ambiguity that would arise without $. These two are identical:

Code: Select all

::set $getInfo, "file"; msg "This is ". $getInfo(file);
::set $getInfo, "file"; msg "This is ". $getInfo . "(file)";
$getInfo(file) is NOT a function but just looks like one! :) And without $ it would be totally indistinguishable from a function getInfo(). QED!
PeterH wrote:Just another question: does RPG require the set-command to set a variable? So there's no construct:
$a = $b;
Or is it just not been defined by you?
RPG? You mean PHP? $a = $b; is not here yet, but I will add that soon. With the new syntax is easy to parse. :)

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

Re: Legal Variables in Scripting

Post by PeterH »

Do I now get you right? I don't know...
At the moment you don't support "functions". So you do not recognize a function call? But then you cannot misinterpret a (non-existent) functionname as a variablename?
But if you had functions? Would $a($b) be the call of the function $a? I'd say yes...
And: words / names separated by undefined special characters (like "(" in this case) are something special? What about $getInfo[info]? (I think this is not, and will not be a function?)

RPG? PHP? :oops: :oops: :oops:
(Sometimes I hate those abbreviations. Especially those I never needed for my own use, as REXX :mrgreen: Never would use that wrong :roll: )

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

Re: Legal Variables in Scripting

Post by admin »

PeterH wrote:Do I now get you right? I don't know...
At the moment you don't support "functions". So you do not recognize a function call? But then you cannot misinterpret a (non-existent) functionname as a variablename?
But if you had functions? Would $a($b) be the call of the function $a? I'd say yes...
And: words / names separated by undefined special characters (like "(" in this case) are something special? What about $getInfo[info]? (I think this is not, and will not be a function?)
As long as I allow interpolation in unquoted strings $a($b)/a($b) is ambiguous, unless it's clear that vars begin with $ and functions do not.

$getInfo[info], or rather $getInfo[$info], is an array to me.

Post Reply