How do I use a variable value in an IF condition

Posted on
Fri Mar 03, 2023 9:31 am
CliveS offline
Posts: 771
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

How do I use a variable value in an IF condition

[MODERATOR NOTE]: this post was initially posted on the topic referencing an example shortcut to get a variable. I've split it into a separate topic because it goes beyond the scope of what that example plugin does, but is a perfectly valid question.
---------------------------------
Just tried your demo and decided to use the get a variable bit in a shortcut to open the front door using a loop to re-trigger the lock as it locks after 10 seconds and sometimes it would be helpful to extend the opening by a re-trigger, but stop once the front door contact sensor opens.

I get the variable but the shortcut ‘If’ statement only gives ‘does not have any value’ or ‘does have a value’ as options and sending nothing to blank the Indigo variable is seen as ‘false’ so it always triggers as ‘does have a value’.

Is their another way to get this working?

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Fri Mar 03, 2023 9:56 am
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Variable Copy Demonstration shortcut

You need to post a screenshot of your shortcut (or at least the section that gets the variable and attempts to do the IF) in order for use to help.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Mar 03, 2023 10:18 am
CliveS offline
Posts: 771
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Re: How do I use a variable value in an IF condition

Screenshot as requested
The variable was blank at this time (- no value - )

Shortcut.png
Shortcut.png (356.56 KiB) Viewed 668 times

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Posted on
Fri Mar 03, 2023 11:18 am
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: How do I use a variable value in an IF condition

Hi Clive, after rereading your post I gave it a try. And spent the next hour trying to figure out what the heck is up with the IF statement.

I've posted another example plugin that shows you how to use the variable value in an IF statement.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri Mar 03, 2023 11:41 am
CliveS offline
Posts: 771
Joined: Jan 10, 2016
Location: Medomsley, County Durham, UK

Re: How do I use a variable value in an IF condition

Thank you Jay, it makes me feel a bit better that it took you an hour to find a way around Apples roadblocks :)

CliveS

Indigo 2023.2.0 : macOS Ventura 13.6.3 : Mac Mini M2 : 8‑core CPU and 10‑core GPU : 8 GB : 256GB SSD
----------------------------------------------------------------------------------
The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 5 guests