how to make a macro variable for efficient looping ?

 

Hi, all I have a looping structure, and want to make efficient looping, if I am now wrong, in the programming langguage there is a macro variable that we can use directly the content of the memory as a object name, so I give the original code look like this :

MaxCount =7;

for (int i=0; i<MaxCount; i++)
{
CreateObjects1("PWT"+i, Colour_1);
CreateObjects1("PWT"+i, Colour_2);
CreateObjects1("PWT"+i, Colour_3);
CreateObjects1("PWT"+i, Colour_4);
CreateObjects1("PWT"+i, Colour_5);
CreateObjects1("PWT"+i, Colour_6);
}

and I want to make a simple looping like this :

MaxCount=7;

for (int i=0; i<MaxCount; i++)
{
CreateObjects1("PWT"+i, &(Colour_+1)) ;
}

the Red Text is what I mean how to make it for macro variable?

Thanks.

rgds bob

 
8
yenpok 2008.02.02 08:59edit | delete

sorry cannot display red text, I change to Bod and Italy font to make it clear.

for (int i=0; i<MaxCount; i++)

{
CreateObjects1("PWT"+i, &(Colour_+1)) ;
}


 
Put the colors in array ( color colour[6] ). I.e.: CreateObjects1("PWT"+i, colour[i]) ;
 

thank edddim, I got it


rgds bob

Reason: