Perm not resolved in menu icon

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".
Post Reply
binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Perm not resolved in menu icon

Post by binocular222 »

Code: Select all

"_Initialize"
	Perm $Test = "<xy>";

"Menu1|$Test" echo Hi
"Menu2" echo Hi
On first run, the icon is empty. On second run the proper icon is shown
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

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

Re: Perm not resolved in menu icon

Post by PeterH »

It seems that when _Initialize is executed, the labels are already scanned and the menu is being built - so the setting of the variable has no immediate effect.
(This scanning is part of finding the _Initialize label - so it must be executed before executing _Initialize.)
Maybe Don could delay resolving the variable for the menu - but it could be rather complicated.

But: just change
"Menu1|$Test" echo Hi
to
"Menu1|<xy>" echo 'Hi 1'
8)
OK: might not be a solution for all other situations :roll:

By the way: the Hi are strings and should be quoted.
The <xy> is a variable and can be specified unquoted. :ugeek:

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

Re: Perm not resolved in menu icon

Post by bdeshi »

:twisted: I think echo Hi was just a quick demo. :wink:
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]

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

Re: Perm not resolved in menu icon

Post by PeterH »

SammaySarkar wrote::twisted: I think echo Hi was just a quick demo. :wink:
Yes.

But would you have been able to swear that this can't have an effect on what was to be tested?
(I've seen things... :shock: )
So I think you always should have a look on those things - it will never make any damage, but sometimes be helpful :P

binocular222
Posts: 1424
Joined: 04 Nov 2008 05:35
Location: Win11, Win10, 100% Scaling

Re: Perm not resolved in menu icon

Post by binocular222 »

LOL. After many years of scripting, I'm still fumbling with quoting.
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488

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

Re: Perm not resolved in menu icon

Post by PeterH »

binocular222 wrote:LOL. After many years of scripting, I'm still fumbling with quoting.
OK: my point of view:

If XY would not accept so many scripting errors, but instead show error messages, maybe also terminate scripts, people would learn much faster.

Every time XY guesses right, the user earns a bit of time.
Every time XY guesses wrong the user looses much time. (And has no help but a non-working script.)

So I'd prefer at least info on every syntax error XY sees.
I think scripters would win a lot of time...

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

Re: Perm not resolved in menu icon

Post by TheQwerty »

Code: Select all

"_Initialize"
   if ($Test == '$Test' || $Test == '') {
      Perm $Test = "<xy>";
      Setting 'AllowRecursion', 1;
      Load '*';
      End true,, true;
   }

"Menu1|$Test" echo Hi
"Menu2" echo Hi
Frankly, I feel '_Initialize' and '_Terminate' should just be avoided most of the time.

You're often better off using a single visible script instead:

Code: Select all

"Show Menu"
   // INIT
   Perm $Test = "<xy>";

   // SHOW MENU
   Load '*', '_Menu1;_Menu2';

   // TERMINATE
   unset $Test;

"Menu1|$Test : _Menu1" echo 'Hi';
"Menu2 : _Menu2" echo 'Hi';

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

Re: Perm not resolved in menu icon

Post by PeterH »

Hey - I often start a script by on-default using the only visible label.

But then to Load '*' with a list of hidden labels: simple, but great idea :appl: :appl: :appl:

Especially, as this might be done variable on demand, e.g. dependent from initialized variables,...

Great :D

Post Reply