10-23-2018 07:39 PM
I have a sub vi that gets called multiple times. Each time the sub vi is called, a new string will be brought in called String IN. I want that string to be stored in a different string variable within this sub VI each time it is called so that the value of String IN is retained each time the subVI is called. For example, the first time this subvi is called, I want the String IN to be stored in String 1, the second time, stored in String 2, etc. My initial thought was to use a while loop and the interval of the while loop to generate a string constant with the number of the interval concatenated to the string to get the name of the variable, then use some property node or something to get the value of that identified variable, but this is where I got stuck since I didn't know how to obtain the value of a variable based on the variable name. Once the value is identified, then I would check to see if it was empty and if not, step through the while loop one more time, and get the next incremented variable to check. If the identified variable was empty, then assign the value of String IN to that variable.
This was the best way I could think to solve this problem, but if another simpler solution exists, please let me know about it, especially if it does not restrict me to however many variables I explicitly create (10 in this case). Maybe using an array of strings would help with that, but I am not sure how to step through the array to assign a string value each time the sub VI is called so that nothing is overwritten.
Solved! Go to Solution.
10-23-2018 08:25 PM
What about a get-set VI that you call on every loop?
Benoit
10-23-2018 10:02 PM
Use an uninitialized shift register on your while loop and use build array to store your strings. You may want to limit how many strings you store since you could build the array until it consumes all of your memory. When you want to select one of the strings from the history use the selection of which string you want to get as the index. Arrays are 0 based so you may want to have your UI use a 1 based value for the user to enter. People do better with counters starting at 1.
10-24-2018 01:17 AM
Hi Ryan,
if another simpler solution exists, please let me know about it, especially if it does not restrict me to however many variables I explicitly create
Whenever you need several elements of the same datatype you should use an array to store those elements!
Please don't use the term "variables" for those frontpanel elements: these are either controls or indicators. According to DATAFLOW they are NOT used for data storage, but as data sources and sinks! Data is stored in shift registers…
10-24-2018 10:09 AM
I apologize, I should have mentioned that I am running LabView 2016. Could you please provide your solution in the earlier version?
10-24-2018 10:17 AM
Thank you, build array was the right way to go here