LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

change name of variable addressed programatically while looping

I am creating a vi which has to set up 24 channels of instrumentation with five different values for each channel.  I need to pass these values as variables to other stages of the vi.  

 

Is there a way to have the same basic variable name with a channel appended and then during the course of looping through all the channels address this variable with one object whose name changes on each loop.

 

For example,  I create InstrumentNameCh0 through InstrumentNameCh23 as variables,  is there a way for the loop to output to InstrumentNameCh"i" where "i" is the loop count.

 

Otherwise, I have to create 24 parallel structures differening only by name. 

0 Kudos
Message 1 of 29
(4,148 Views)

A "format Into String" node inside a For loop will meet the specs you have specified.

 

 

 

Ben

Message Edited by Ben on 03-13-2009 11:38 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 29
(4,138 Views)

wildcatherder wrote:

For example,  I create InstrumentNameCh0 through InstrumentNameCh23 as variables,  is there a way for the loop to output to InstrumentNameCh"i" where "i" is the loop count.


I guess I don't quite understand what you mean by "variable" in this context. Can you attach a small example VI?

Message 3 of 29
(4,131 Views)
That is an excellent way to CREATE the local variable name but I need to reference (write to or read from) an already created local variable name in a loop with a different name on each pass.  I don't see how the technique you describe could be used for that purpose.
0 Kudos
Message 4 of 29
(4,117 Views)

wildcatherder wrote:
That is an excellent way to CREATE the local variable name but I need to reference (write to or read from) an already created local variable name in a loop with a different name on each pass.  I don't see how the technique you describe could be used for that purpose.

 

Now I am baffled (nless you are trying to access a value by passing its name).

 

Please post an image of what you said you know how to do but would require a lot of duplication. With that we may be better able to help out.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 29
(4,113 Views)
Would it make sense to use a case structure, with cases for each of the possible local variables and assign or retrieve them in the case structure?
-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 6 of 29
(4,104 Views)

So while we are waiting for clarification....

 

An Action Engine With acton like

 

Init - Accepts an array of the names and optionally the initital values. There should be a 1-to-1 relation between the names and the values. Store ths in a SR

Set Value - This action accepts a string and a numeric. The string is used by a serach 1d aray from the names soter in the SR. If the index is value do a replace array subset for the value. Update the SR

Get_Value - This action is similar to above but it indexes out the value for the SR and returns same to the caller.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 7 of 29
(4,098 Views)
Sounds good to me Ben.
-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 8 of 29
(4,095 Views)

Thanks Matt!

 

Don't know if it is getting close to the original query or not. Here is an image to go with my pvious outline for the AE.

 

 

 

Ben

Message Edited by Ben on 03-13-2009 02:34 PM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 29
(4,083 Views)

Case structure would work but would still require me to write in each case.  I am trying to to read and write to front panel displays by means of local variables.  The variables are named similarly for all 24 channels with the channel number appended to the "base name".  I would like to loop through these channels, performing various string/data conversions, by making the local variable name itself some kind of variable.

 

Thanks 

0 Kudos
Message 10 of 29
(4,079 Views)