LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use "for" loop to output a series of text string one by one?

In the attached sample VI, I am trying to output a text string to the string indicator-string3, The string2 is a constant text string "I am". i would like to have the string3 show "i am0" , "I am1", "I am2", "I am3", "I am4", one by one, but with the attached VI, i can only shown "I am4", anyone can tell me how to modify this VI? I don't want to put the string3 indicator inside the "for" loop for other application purpose.

 

Thanks.

 

John 

0 Kudos
Message 1 of 15
(4,323 Views)

John,

 

Not sure what you are trying to accomplish, but try this to see if it brings you closer to a solution.

 

Right click on the output of the for loop and select "Indexing" This will give you an array output of each string created in the loop. Then you can use the index array function in other parts of the code to select the correct string to display.

 

Dan

 

0 Kudos
Message 2 of 15
(4,317 Views)

John,

 

See the following example....  LV 2011 - Let me know if you need it in a different version.

 

Dan

 

 

Message 3 of 15
(4,312 Views)

Dan,

I have tried your solution, but the problem is that i can only get the display on String3 after all five "for" loop are accomplished. Can i show the result from each "for" loop instantly?

 

John

0 Kudos
Message 4 of 15
(4,309 Views)

Sorry, my labview version is 8.5.

0 Kudos
Message 5 of 15
(4,308 Views)

Hello,

 

 

Attached is LV 8.5 VI.

 

 

Regards,

 

Bijay

0 Kudos
Message 6 of 15
(4,304 Views)

Bijay,

with your solution, I still get the same problem as Dan's solution, i can only show the result after all five "for" loop are accomplished. The  content in string3 is actually commands to be written to a linear XY stage. The stage controller can not accept commands in a array, it can only accept a command one by one, i also want to send the command to the stage controller every 2 minites, so i need to set the waiting time in each "for" loop. With your solution, i could not set up this waiting time.

 

John

0 Kudos
Message 7 of 15
(4,299 Views)

John,

 

I've just downconverted Dan's VI. As you have mentioned in your first post,Dan's VI works good.

 

Regards,

 

Bijay

0 Kudos
Message 8 of 15
(4,283 Views)

I could not open Dan's VI, can you send me the 8.5 version?

 

John

0 Kudos
Message 9 of 15
(4,278 Views)

Try this. The Wait ms is there only to allow you to see the updates to the value of Command. Without it you would only see the last value even though each is written to the indicator. They are just written so quickly you don't see it.

 

Simple For Loop.png



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 10 of 15
(4,273 Views)