How to test the value of a local variable

I checked the new docs, but still can’t figure this out.

Neither of these work:

        <If variable="vcat" is value='start' >
        <If variable="{Get local=vcat}" is value='start' >

Cheers, Richard

I tested this out yesterday and also noticed that the ‘variable’ condition didn’t work with local variables. You’ll want to use check=“{Get local=my_variable}” (sorry about the formatting I’m on mobile)

@benjamin Thanks.

Wouldn’t that only tell me that the variable exists, but not the value of the variable?

Nope! ‘Check’ is definitely the most versatile of the core conditions. I use it any time there isn’t another core condition specifically built for the kind of data I’m trying to work with. If you just wrote <If check=“{Get some_variable}”> then it would work as you’re suggesting, but you can add comparisons and a value to that condition just like you can with any other.

I’m prepared to feel foolish, so here goes

       <Get local=vcat />
       <If check=“{Get local=vcat}” is value="start" >
          It is start

The first line prints out the correct value which is: start
The If statement prints nothing.

I must be missing something.


That’s the correct syntax, but I think your issue is that you’re using the wrong quotation mark symbol. I’m on mobile so my " is being changed to “ so that’s my fault for leading you astray there haha :stuck_out_tongue:

Great catch. Ironically, I actually tried single quotes around the value to see if it would matter. Cheers.

The new docs for <If> say:
If no comparison is given, the default is 'exists'.

However, in the example for check no comparison is given, but it apparently functions as if the default comparison would be: is

I think not seeing a comparison there is what led me away from using check

Good catch, I’ll have to check with the devs to confirm but I think that part of the docs should probably say “If no value is specified, the default comparison is ‘exists.’ If a value is specified, the default comparison is ‘is.’” This is pretty intuitive when you think about it but it would be worth clarifying so I’ll update the new docs accordingly.

So in practice, writing this would use the comparison ‘exist’:

<If check="{Get local=some_variable}">

And writing this would use the comparison ‘is’:

<If check="{Get local=some_variable}" value="some value">

Thanks. Maybe it’s only me, but I feel that examples in documentation should not use “shortcuts”.

That’s because people looking at the examples are trying to wrap their heads around the concept, and shortcuts only confuse matters. People who are ready to use shortcuts probably aren’t looking at the examples anymore.

I consider leaving out exists or is to be shortcuts. It would make more sense to me to explain they are defaults, but show them in the examples so the examples are consistent with the general case.

That way the examples are “self-contained”. You don’t need to remember or look up what defaults have been omitted.

Cheers, Richard


Thanks for the feedback, I’ve updated the docs accordingly. Let me know if you have any other suggestions or issues with the documentation and I’d be happy to incorporate them. Always looking for ways to improve!