Hi, am trying to set @label based on a global variable using
@if:$glob:BackgroundChanger_highlight=true
@label:="On"
@if:else
@label:="Off"
but cannot get it to work, shows off always
Is it even possible ?
BackgroundChanger_highlight is set in a script and works with
@toggle:if $glob:BackgroundChanger_highlight
Leo
September 1, 2024, 6:42pm
2
Lines with @modifiers are all processed before any conditional branching happens, which is why the original approach wouldn't work.
You can do everything in a single @label line that uses Evaluator code to decide which label to use.
I’m not at a PC currently but can provide more detail later if it’s needed.
thanks, helps a bit.
@label: = return ($glob:BackgroundChanger_highlight) ? "on" : "off";
this works sometimes - when on the toolbar it is not updating properly, when tucked away in a menu it does update.
Leo
September 2, 2024, 11:32am
4
You probably aren't telling the toolbars to update after you change the variable.
@toggle:update
if it's in a button changing it, or command.UpdateToggle()
if it's a script.
Again, helps a bit. Thanks.
Starting the slideshow the label will update after the second image has been displayed.
Stopping the slideshow. The label will not update, but clicking it will update it.
Was hoping eventually for some sort of count down time left till next image, - useful for longer durations (24 hours, etc.) - though would mean continuously updating the toolbar label buttons every millisecond ? second ? minute ? and also putting some sort of return from PeriodicTimer() = time left till next event.
Leo
September 2, 2024, 4:42pm
6
Sounds like you may be triggering the update before changing the variable instead of after.
Awesome got it working now, many thanks.
Using
command = '@toggle:update';
cmd.AddLine(command);
cmd.Run();
after setting the @glob
works.
Leo
September 3, 2024, 7:26am
8
The proper way to do it from a script was given above:
Leo:
command.UpdateToggle()
Thanks again, much neater and much appreciated.