Hi. I have ten variables, myvar1, myvar2 ... myvar10, and would like to run a conditional statement on them. For example, is myVar1 greater than the other nine variables, myvar2 through myvar10. Rather than write nine separate conditional statements I'd like to use one conditional within a loop. Something like the following:
for(i=2; i < 10; ++i) {
i= toString();
if(myVar1 >= FORMAT UNKNOWN) {
Color0=Color.lime }
}
First question, am I correct that I need to convert "i" to a string?
Second question, where I have written FORMAT UNKNOWN what would be the correct format to concatenate the "i" strings to a base variable, for example myvar+"i" to generate myvar2, myvar3, etc.?
Finally, would I then need to convert "i" back to a number object by multiplying it by 1? E.g. inserting the line
i=i*1;
before the final bracket? Thanks for any suggestions.
Mike
for(i=2; i < 10; ++i) {
i= toString();
if(myVar1 >= FORMAT UNKNOWN) {
Color0=Color.lime }
}
First question, am I correct that I need to convert "i" to a string?
Second question, where I have written FORMAT UNKNOWN what would be the correct format to concatenate the "i" strings to a base variable, for example myvar+"i" to generate myvar2, myvar3, etc.?
Finally, would I then need to convert "i" back to a number object by multiplying it by 1? E.g. inserting the line
i=i*1;
before the final bracket? Thanks for any suggestions.
Mike
Comment