LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to name the last iteration differently?

Solved!
Go to solution

Hello,

 

I have a simple while loop that allows the user to chose the number of iterations. In every iteration, I have a string that shows a constant name (ABC). So in the first iteration, the indicator will show ABC0, 2nd iteration ABC1, 3rd iteration ABC2 and so on. Now I want the last iteration to add a constant name (bgd) to the end of the first part (ABC).

 

So let's say the user chooses 3 iterations. I want the code the show the followings:

ABC0, ABC1, ABC2, ABC3bgd

 

However I don't know how to program this since the user has the power to choose the number of events. I have attached this simple code here. 

 

Any help is greatly appreciated. 

0 Kudos
Message 1 of 4
(2,633 Views)

If you know the number of iterations beforehand, a FOR loop is often a better option than a WHILE loop.

Haven't looked at the code yet, but it seems odd to enter THREE iterations, to produce FOUR names.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 2 of 4
(2,624 Views)

Now I want the last iteration to add a constant name (bgd) to the end of the first part (ABC).

 

So let's say the user chooses 3 iterations. I want the code the show the followings:

ABC0, ABC1, ABC2, ABC3bgd

 

This is not consistent.  if you want THREE iterations, then BY DEFINITION, your last one is iteration TWO.

That's the rule.

 

However, here's something to produce the result you asked for:

Iterations.PNG

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 3 of 4
(2,614 Views)
Solution
Accepted by topic author Sina90

If you know how many iterations you are doing, you just do a comparison with the i terminal to see if you are on the last iteration.  If you are, add your extra string.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 4
(2,606 Views)