GP SoftwareTwitter
Opus FAQsManualCommandsObjects

DO11: [FR] Test @set variables with @toggle?

Is there some syntax I'm overlooking that would let you test a variable set by @set in the @toggle directive?

If not, could there be? I think the prospect of using variables as a toggle for script behavior would be really useful... example:

[code]@ifset:$lst:autosize
@set lst:autosize=

@ifset:else
@set lst:autosize=true[/code]
...would be great to include something in a button like this like: @toggle:if $lst:autosize so in the use case as a script behavior toggle, a toggled ON state would be evident visually.

In case this already worked and I just wasn't using correct syntax, none of these worked :slight_smile::

[code]@toggle:if lst:autosize
@toggle:if lst:autosize=true

@toggle:if $lst:autosize
@toggle:if $lst:autosize=true

@toggle:ifset lst:autosize
@toggle:ifset lst:autosize=true

@toggle:ifset $lst:autosize
@toggle:ifset $lst:autosize=true

@toggle:ifset: lst:autosize
@toggle:ifset: lst:autosize=true

@toggle:ifset: $lst:autosize
@toggle:ifset: $lst:autosize=true

@toggle:ifset:lst:autosize
@toggle:ifset:lst:autosize=true

@toggle:ifset:$lst:autosize
@toggle:ifset:$lst:autosize=true[/code]
...I know we can't test 'actual' @set 'values'.

And by the way, on second thought - maybe it's not even necessary to ACTUALLY enable @toggle to check for @set variables... in most cases, the ability to call @toggle with explicit on|off args might be all we might need? Would this be easier for you to implement:

[code]@ifset:$lst:autosize
@set lst:autosize=
@toggle:off

@ifset:else
@set lst:autosize=true
@toggle:on
SmartGetSizes GETALL NODESELECT[/code]
...since we can already just use @ifset to check for the variable of interest, we could then just make explicit on|off calls to @toggle within the body of the @ifset test?

Added [FR] to subject since it seems this can't already be done and I'm not just flubbing the syntax...

I've only had time to skim this thread but does DO11: Using @set to "toggle" commands? cover it?

That thread is relevant, sure... but what you helped newguy sort out there was something I'd already done in my own example in this thread re: toggling a variable using a button. What we're BOTH still after is a way of toggling the highlight state of the button along with the state of the variable as a visual indicator of the variable state. I had also thought of a "hack" like the one newguy came up with (Set SOUNDS=Toggle) but that's really no good.

When I opened this thread, I had hoped that the changes you guys made to @toggle to be able to test regular Set command states extended to @set variables as well. But it appears not to. So I figure this is a feature request that could best be tackled in one or two ways:

One way would be to let @toggle test for @set variables using something like this syntax:

@toggle:if $lst:varname

Which fits both mine and newguys needs, and I think also fits in the context of what you did to allow @toggle to test regular Set command states, however:

An explicit 'toggle on/off' capability that would work something like:

[code]@ifset:$lst:var
@set lst:var
@toggle:off

@ifset:else
@set lst:var=on
@toggle:on[/code]
...would be more open ended so people could use it in buttons that might not use EITHER any commands that natively affect the button highlight state OR any use of @set variables like newguy and I are using.

I'd be thrilled with either approach - but maybe the first fits better with the current model. At least, it seems to be a natural extension to @toggles ability to test Set commands just like you enabled @ifset to test @set variables where it could previously only test Set command states.

There's no way for scripts to set the toggle states of buttons. We may add that in the future, but it's out of the scope of what we're doing for 11.0 (and in particular would have performance issues unless done properly, which we need to think about)

(We might be able to do something specific for variables, though.)

Scripts? I'm talking about in the button, same place that you normally use @toggle. The only relation to scripts mentioned in this thread had to do with the prospect of using normal Opus buttons to toggle an @set variable that a script could then use as a flag on whether or not to perform it's function in addition to the event that invokes.

In a normal Opus button even without scripts involved, @ifset used to only be able to test regular Set command states (VIEW, etc). In v11, @ifset can now also test the state of variables set with @set. Also in v11, you've enabled @toggle to test regular Set command states. So, I'm asking that you help @toggle catch up to @ifset.

Thanks for the further explanation, I think this should be possible for the next beta.

Thanks very much - and sorry if it wasn't clear, should have put a clearer 'actual' example to help explain. For posterity, as two real-world examples of how this would be useful:

An example of my use-case would be to have button like so:

[code]@toggle:if $scriptvar

@ifset:$lst:scriptvar
@set lst:scriptvar

@ifset:else
@set lst:scriptvar=true[/code]
...with the idea being that there is a script running on startup watching for whatever event it's registered for, and which will 'always' fire on that event. But I only want the script to actually execute it's intended functions when a certain variable is set by the user, and if that var is not set, to just return without doing anything. I want the user to be able to use a button like the one above to toggle the variable on and off, but to also have a visual indication that the button (and the variable it's toggling) is in fact 'On' or 'Off'.

Very similar to what newguy wanted to do in that other thread, where he's maybe now using the hack of running some other 'Set' command just to toggle the button highlight, I'm sure he'd much rather be able to do something like:

[code]@toggle:if $glob!:HDMIAudio

@ifset:$glob!:HDMIAudio
@set glob!:HDMIAudio

@ifset:else
@set glob!:HDMIAudio=1
[/code]

Woohoo! Thanks alot for this in B5! I'm gonna have to go ahead and put on some good episodes of Babylon 5 while I play with Opus 11 B5 for a little while now...