Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get variable data from outside of For Loop for changing variables value in each iteration

Hi, I want to get some variable data which will varying within the for loop with changing each iteration. I want to use those varying data to control another loop simultaneously. I have trying by converting those variable into local variable. But, I can not get data from local variable from the outside of for loop. I get data from local variable only when loop has finished. In case of using while loop, I can get variable data from outside the loop. I don't know how I can do solution of this problem. Please suggest me. Thank you very much.

0 Kudos
Message 1 of 4
(6,085 Views)

If you cannot read a local variable in another loop, you have made a large mistake in your program. Attach your code.

 

 

0 Kudos
Message 2 of 4
(6,080 Views)

Hi

I was trying to do the same thing, access a variable in a for loop outside the for loop and before it is done executing.

 

I tried local variables which did not work, so I used a global variable and it works fine.

I am just curious about what u mentioned...is therre any drawbacks to using global vs local variables?

 

The reason i need this is that my for loop will run 100 times, and i need the data every 10 iterations,so on iteration 10, 20, 30,...

I cannot wait for the for loop to finish, so I need to have immediate access to the variable.

 

Thanks!!


 

0 Kudos
Message 3 of 4
(5,793 Views)

developer001 wrote:

The reason i need this is that my for loop will run 100 times, and i need the data every 10 iterations,so on iteration 10, 20, 30,...


 This is sounding like you should be using a queue instead.  That way you don't miss any data in case a process starts to lag for whatever reason.


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
0 Kudos
Message 4 of 4
(5,790 Views)