Page 1 of 1
Perm not resolved in menu icon
Posted: 08 Mar 2015 04:18
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
Re: Perm not resolved in menu icon
Posted: 08 Mar 2015 12:10
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'
OK: might not be a solution for all other situations
By the way: the Hi are strings and
should be quoted.
The <xy> is a variable and
can be specified unquoted.

Re: Perm not resolved in menu icon
Posted: 08 Mar 2015 13:28
by bdeshi

I think echo Hi was just a quick demo.

Re: Perm not resolved in menu icon
Posted: 08 Mar 2015 13:51
by PeterH
SammaySarkar wrote:
I think echo Hi was just a quick demo.

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...

)
So I think you always should have a look on those things - it will never make any damage, but sometimes be helpful

Re: Perm not resolved in menu icon
Posted: 08 Mar 2015 14:05
by binocular222
LOL. After many years of scripting, I'm still fumbling with quoting.
Re: Perm not resolved in menu icon
Posted: 08 Mar 2015 14:17
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...
Re: Perm not resolved in menu icon
Posted: 09 Mar 2015 11:18
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';
Re: Perm not resolved in menu icon
Posted: 09 Mar 2015 16:37
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
Especially, as this might be done variable on demand, e.g. dependent from initialized variables,...
Great
