You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Automate
I'm trying to understand how choice selection, + and ++ works; from the documentation:
To number + An unary prefix operator that returns the operand converted to a number; +"2" returns 2, +"0xFF" returns 255.
To text ++ An unary prefix operator that returns the operand converted to text; ++2 returns "2".
I made a Choice dialog with the index saved in a variable test, then tried logging:
test + 1 = NaN, so test content isn't a number +test + 1 = NaN; if test isn't a number, why +test added to a number gives NaN? ++test + 1 = 2; if ++test is text, why it can be added to a number to give a number?
Henrik "The Developer" Lindqvist
unread,
Sep 29, 2022, 9:47:10 AM9/29/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Automate
As the documentation say, "Note! The selected indices/keys output variable is assigned an array
even when only a single choice is possible. To get the first or single choice index/key use the subscript operator,
e.g.: selected[0] or choices[selected[0]]."
So you should probably do: test[0] + 1
Mauro
unread,
Sep 29, 2022, 1:30:13 PM9/29/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Automate
Thanks, I missed that, it works. Why though + and ++ work like that in this case? Given test + 1 gives NaN, I'd have guessed +test + 1 to be a number, and not ++test + 1, since ++test being a text I thought that it would give NaN in a sum.
Henrik "The Developer" Lindqvist
unread,
Sep 29, 2022, 1:59:02 PM9/29/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Automate
+A is for converting A to a number, but an array can't be converted to a number thus resulting in NaN.
A + B is only for addition, adding array + 1 is invalid since see above.
++A is for converting A to text.
A ++ B is only for string concatenation.
Mauro
unread,
Sep 29, 2022, 2:05:30 PM9/29/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Automate
Then why if test[0] = 1 (only element) then ++test + 1 = 2? Seems like "Convert to text an array containing only 1 and add 1, the result is 2".
Henrik "The Developer" Lindqvist
unread,
Sep 29, 2022, 2:12:46 PM9/29/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Automate
++test will convert the array to text, e.g. [ "1", "2" ] to "12" or [ "1" ] to "1"
A + B will convert each operator to a number, A to 1 and B to 1, then
1+1 = 2
8li...@gmail.com
unread,
Sep 29, 2022, 2:13:32 PM9/29/22
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Automate
sometimes it is easier to look at an example flo in the community
ב-יום חמישי, 29 בספטמבר 2022 בשעה 00:05:26 UTC+3, Mauro כתב/ה: