12-07-2016 05:13 PM - edited 12-07-2016 05:15 PM
I'm working on a project to create an "opening hand simulator" for a Magic: the Gathering deck. In my head, the idea is that I create a VI to shuffle a 60-card deck and display the top seven cards.
Well, I have the first part working fine - I have a VI that creates an array with values from 0 to 59, randomizes it, and then displays the first 7 values of the array. In other words, I hit Run and it spits out seven random numbers from 0-59 with no duplicates, just like if you shuffle a 60-card deck and draw seven cards.
But I want to go a step further and assign a string value (the name of a Magic card) to each numerical value in the array - so, 0 = "Island", 1 = "Lightning Bolt", and so on. That way when I hit Run, I will get a display of seven card names instead of seven numbers.
So, how would I go about 1) assigning a string value of my choice to each of the 60 numerical values in this array, and 2) display the values of this randomized array as the aforementioned string values?
Solved! Go to Solution.
12-07-2016 05:18 PM - edited 12-07-2016 05:25 PM
Several options here, but the easiest i see is to use the numerical values to localize an array of strings. So have a separate array of strings, and use the numerical values to index the array and pull the string at that index value.
[edit] Example:
12-07-2016 05:42 PM
That worked perfectly, thanks!
12-09-2016 07:00 PM
hi, taking advantage of your suggestion... what if i have an array of a hundred strings but in my front painel i just want to display 4 strings that will be selected automatically. in my cases the strings in my front painel will be alarms, so i have a hundred possible alarm messages that shall be displayed when the corresponding boolean is set true.
thank you.
12-09-2016 08:05 PM
Can you pose a snippet of your most recent code? Add some comments to Portray what you're trying to accomplish. I'm just a little confused what you're trying to do.
12-10-2016 05:29 AM
Hi, i am sending an example describing what i want to do. And rembering that i don't know if my approach is the best one, so if you have a solution using other elements it will be welcome.
thank you in advance.
12-12-2016 10:48 AM
I would try something like this. You had several alarm elements, i just put those into an array, arrays are generally much easier to work with than several of the same type elements.
12-12-2016 03:37 PM
Thank you very much. It worked perfectly.
12-12-2016 04:04 PM
@Wolleee wrote:
I would try something like this. You had several alarm elements, i just put those into an array, arrays are generally much easier to work with than several of the same type elements.
Use an enum type def and those strings can travel places without having to update the string array constants in several places each time you add a new alarm
(Look ma no case struscture to hide code in)
12-13-2016 03:29 AM
Thank you too, i'll try. I never saw this conditional tunel, looks interesting.