store value in for-loop

 

Hi guys,

is it possible to store a value inside a for-loop so that I can use this value for further calculations outside the for-loop?

 
Hello fellow, yes of course it is possible!
 
Carl Schreiber:
Hello fellow, yes of course it is possible!


Haha I should have given an example. Let's assume this:

for(int i = 0,i <= 3; i++)
{
if(i == 2)
	a = i;
	// ---> store a
}
// then further calculations with a

So, how can I store a? I kinda struggle with that task..

 
int a=0;

for(int i = 0,i <= 3; i++)
{
if(i == 2)
        a = i;// ---> store a
        
}
// then further calculations with a

Alert(IntegerToString(a));
 
Marco vd Heijden:

Well done. That works perfectly. Many thanks