quotes in function-variables (<get >, <prop >)

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".
admin
Site Admin
Posts: 67271
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Scripting Bugs

Post by admin »

... and beyond. :mrgreen:

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

Re: Scripting Bugs

Post by PeterH »

admin wrote:I share TheQwerty's mixed feelings about this. All these work now, and some of them do look a bit funny:

Code: Select all

echo  <get "genericfiletype" '{:Image}'>;
echo  "<get "genericfiletype" '{:Image}'>";  //hmm...
echo  "<get ""genericfiletype"" '{:Image}'>";  //hmm...
echo  eval("<get " . "genericfiletype" '{:Image}'>);
$g = genericfiletype; echo  eval(<get "$g" '{:Image}'>);
For me it shows that there's something wrong in the concept. (Beside the situation, that stacking quotes often looks quite strange...)

But in general: what's a constant, and what's a variable? For example:
$g = genericfiletype; echo eval(<get "$g" '{:Image}'>);
OK: the left side must be quoted if I'm right: $g = 'genericfiletype';
So $g is a variable containing a string. Then in
echo eval(<get "$g" '{:Image}'>);
$g is a variable :biggrin: and *may* be in double quotes. I think this is in conflict with your definition, as I think(!) you use the quotes to recognoize the 1st "operand" for the get?

For me:
echo <get "genericfiletype" '{:Image}'>;
is straight forward as expected. (The complete <get ...> is a special *variable* and can be used unquoted.

echo "<get "genericfiletype" '{:Image}'>"; //hmm...
For me this looks like a syntax error :-(

echo "<get ""genericfiletype"" '{:Image}'>"; //hmm...
Formally it looks clean :arrow: inside double quotes: double double quotes, use single quotes. (The latter looks better...)

echo eval("<get " . "genericfiletype" '{:Image}'>);
:shock: is this a concatenation of parts of a variable???
Then for "abc=$abc" you should be able to write "abc=$a"."bc" :shock:

Back to the roots: what are these "operands" in a <get ...>?
- they might be strings ==> must be quoted
- they might be codewords ==> unquoted, but no operand may contain spaces.
And the latter is unusual for XY: operands usually don't use codewords ( Status "msg", "ff0000", "alert"; ) Here alert is a string (representing a codeword), not a direct codeword. Advantage af a string: can be replaced by a variable - a codeword can't.

So I'm afraid: some thinking is required - or syntax can't become clean.
The root of problems seems to be a "variable" <get ...> containing strings.

(By the way: there *are* codewords, that are no strings: get, or substr for example.)

Sorry for long post, wasn't able to get it shorter :oops:

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

Re: Scripting Bugs

Post by admin »

These were just some partly extreme examples of what works. I did not mean them to be suggestions.

The recent changes were done to achieve more consistency between get(...) and <get ...>.

But there is at least one fundamental syntactic difference:
In get(...) arguments are separared by commas, therefore arguments containing a comma MUST be quoted.
In <get ...> arguments are separared by spaces, therefore arguments containing a space MUST be quoted.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Scripting Bugs

Post by bdeshi »

Seeing the blatant and horrific disregard for sanity syntax that the newly risen <get > displays, I'm tempted to say the old way was better; not "better" better, "less worse" better.
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Scripting Bugs

Post by admin »

The old way is still there.

bdeshi
Posts: 4256
Joined: 12 Mar 2014 17:27
Location: Asteroid B-612
Contact:

Re: Scripting Bugs

Post by bdeshi »

can't deny that. So there's a compromise: either strict quotes or quotes galore!

"The new way" is not really unbearable and more than what I wanted, but only creates a different kind of headache.
how do you make this work anyway?

Code: Select all

echo  "<get "genericfiletype" '{:Image}'>";  //hmm...
is it interpreted like this?

Code: Select all

echo "<get ". genericfiletype . " '{:Image}'>";
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

TheQwerty
Posts: 4373
Joined: 03 Aug 2007 22:30

Re: Scripting Bugs

Post by TheQwerty »

Can we just stop using the variable version of Get in places where it makes no sense?

It only exists to provide access to the capabilities of the Get command in places where scripting is not available - the title bar template being the main one.

If you are writing a script there is absolutely no reason to ever use <get ...> or <prop ...>.

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

Re: Scripting Bugs

Post by PeterH »

TheQwerty wrote:Can we just stop using the variable version of Get in places where it makes no sense?

It only exists to provide access to the capabilities of the Get command in places where scripting is not available - the title bar template being the main one.

If you are writing a script there is absolutely no reason to ever use <get ...> or <prop ...>.
Makes sense? Lazyness? :roll:

You can use <get ...> inside a double-quoted string.
With get() you have to break the string into parts, and use concatenation.

I think in the end you are right: the format of <get ...> being a variable, but containing "internal strings", isn't really good for scripts. The syntax doesn't really fit.
But it's there. So sometimes you are tempted... :whistle:

Post Reply