06-07-2018 09:30 AM
Hi,
First of all sorry for my English. I have two string variables in combo box or enum such as;
variable 1: "A","B","C","D" and variable 2: "A","B","C","D".
i want to write result of combinations of these variables on screen (as string) like;
if variable 1=A and variable 2=A then result=X,
if variable 1=A and variable 2=B then result=Y,
....
if variable 1=B and variable 2=C then result=T,
I tried to do it in case structure but i couldn't do it. string output is not possible In formula node. also i dont want to do it with formula node. Thanks for your help and messages.
06-07-2018 09:40 AM
You can do something like concatenate the combo strings and use a case on the result. But it gets more unmanageable the more options you have for the two combos.
06-07-2018 10:05 AM
Create an array lookup table and use your enums as the row/column index.
06-08-2018 02:06 AM
can you upload example 1.vi at LAbview 16.0 version? thank you
06-08-2018 11:45 AM
is there a reason not to do it like this?
As for formula node not outputting a string you could output the ASCII for the character and type cast to string outside the node.
06-08-2018 12:04 PM
@Aputmans idea is great!
/Y
06-08-2018 12:16 PM - edited 06-08-2018 12:33 PM
the lookup-table and the nested case-structures are totally valid,
but i had some cases where i used something like the following to have less code repitition/more flexibility.
which is equivalent to
and for good measure this came also to mind:
06-08-2018 01:56 PM
@jwscs wrote:
the lookup-table and the nested case-structures are totally valid,
but i had some cases where i used something like the following to have less code repitition/more flexibility.
which is equivalent to
and for good measure this came also to mind:
I like the Look-up table approach myself. If working with a-z we have at worse a 26X26 matrix to populate.
Editing 600+ cases is not to my liking.
Ben
06-08-2018 02:02 PM
if it is really only a value that is the output of that, but i thought more in the lines of actions taken, that will be encapsulated by the cases. anyways .. was just for the fun of it 😉
06-08-2018 03:29 PM
IMHO which method is best to use may also depend on how many distinct cases there are. The OP didn't give much to go on.
For a small number of distinct cases, using lists & ranges could be easier to manage. ex.
Case 1: "aa", "ab", "ac"
Case 2: "ba", "bf"
Case 3: "ca".."cz"
Case 4: Default
For a LUT, you would have to populate ALL the entries in the table regardless, and finding a typo in a 600+ LUT may be like trying to find Waldo.
BTW the second example by jwscs could be simplfied. Instead of using a logical shift, integer convertion, and addition it could be done like this