I am using the Input Dialog to have the user provide a Single Choice. This Single Choice is in text and is one of four possibilities:
"Sleeping Pills"
"Test Cassettes"
"NovoRapid"
"Lantus"
When the user chooses one of these option though I want a "number" copied to clipboard, i.e.
If user chooses "Sleeping Pills" then "1234567" is sent to clipboard
If user chooses "Test Cassettes" then "2345678" is sent to clipboard
If user chooses "NovoRapid" then "3456789" is sent to clipboard
If user chooses "Lantus" then "4567890" is sent to clipboard
I tried using an embedded "If" statements in script to do this (i.e. If "Sleeping Pills" then make a variable = "1234567" else if, else if, etc. then copy variable to clipboard), I also tried using compounded Conditions (in a similar fashion as if statements) to do this. But the only time it seems to work is when the first choice ("Sleeping Pills") is chosen, otherwise "null" is copied to the clipboard. It's as though after the first If statement is executed the {value} variable loses it's value or something, I don't get it... any thoughts? Thanks!
Multiple/Embedded If's ... should that work?
Moderator: Martin
-
- Posts: 4
- Joined: 16 Jan 2014 16:55
Multiple/Embedded If's ... should that work?
I Try Soooo Hard!
Help Me! =)
Help Me! =)
Re: Multiple/Embedded If's ... should that work?
Try initializing variable before anything else:
Variable = "some value";
If (condition)
.......;
Else
......;
If (.....)
.....;
And so on
Variable = "some value";
If (condition)
.......;
Else
......;
If (.....)
.....;
And so on
-
- Posts: 4
- Joined: 16 Jan 2014 16:55
Re: Multiple/Embedded If's ... should that work?
Thanks for the reply mcyber.
I tried that just now but it didn't work. I applied the value from the Single Choice Input Dialog - {value} - to a variable called "choice_text" (choice_text = {value};) first then changed the if statements to evaluate using the "choice_text" variable instead but again, it only works if the first choice "Sleeping Pills" is selected, all other choices result in "null". Mind you the first choice "Sleeping Pills" is also the default value as well ...
I tried that just now but it didn't work. I applied the value from the Single Choice Input Dialog - {value} - to a variable called "choice_text" (choice_text = {value};) first then changed the if statements to evaluate using the "choice_text" variable instead but again, it only works if the first choice "Sleeping Pills" is selected, all other choices result in "null". Mind you the first choice "Sleeping Pills" is also the default value as well ...
I Try Soooo Hard!
Help Me! =)
Help Me! =)
Re: Multiple/Embedded If's ... should that work?
Here's a part of one of my flows. You should be able to use this as a reference for working out your case.
http://automagic4android.com/flow.php?i ... e18a30ea96.
http://automagic4android.com/flow.php?i ... e18a30ea96.
-
- Posts: 4
- Joined: 16 Jan 2014 16:55
Re: Multiple/Embedded If's ... should that work?
Thanks as well MURTUMA,
I used the index method instead (not sure why I didn't before), however now the clipboard text is always "1" no matter what option I choose (whereas before it was "1" for option 1 "Sleeping Pills", but "null" if I selected any other option).
I've attached an xml of my Flow if you want to take a look at it. I don't see anything wrong ...
I used the index method instead (not sure why I didn't before), however now the clipboard text is always "1" no matter what option I choose (whereas before it was "1" for option 1 "Sleeping Pills", but "null" if I selected any other option).
I've attached an xml of my Flow if you want to take a look at it. I don't see anything wrong ...
- Attachments
-
- exported_data_20140116_164554.xml
- Flow 01-16-2014
- (3.28 KiB) Downloaded 860 times
I Try Soooo Hard!
Help Me! =)
Help Me! =)
Re: Multiple/Embedded If's ... should that work?
Indexes are zero based, so in your script should read "if index ==0" and so on.
http://automagic4android.com/flow.php?i ... 16e2d53183
http://automagic4android.com/flow.php?i ... 16e2d53183
-
- Posts: 4
- Joined: 16 Jan 2014 16:55
Re: Multiple/Embedded If's ... should that work?
Woohoo!! Alas ... it works! Thanks everybody!
Cheers!
Cheers!
I Try Soooo Hard!
Help Me! =)
Help Me! =)