[FMX] dynamic if problem

I tried to make a dynamic if, but it just doesn’t work…

line = “a == 1”
for (i = 2; i<=5;i++){
line += " || a == " + i;
}

a = 1;
if (line) {
trace(“works”)
}

but if I use the concatenated final line, it works:

line = “a == 1”
for (i = 2; i<=5;i++){
line += " || a == " + i;
}
a = 1;
if (a == 1 || a == 2 || a == 3 || a == 4 || a == 5) {
trace(“works”)
}

who knows what’s going on??

what im sure of is your second one is always going to return an ok value:

line = "a == 1"
for (i = 2; i<=5;i++){
line += " || a == " + i;
}
a = 1;
if (a == 1 || a == 2 || a == 3 || a == 4 || a == 5) {
trace("works")
}

since you tell flash that a=1 and then say if a ==1 then trace “works”

the problem is that:


line += " || a == " + i

it’s supposed to turn into a true of false argument, there it will turn into a string text since you have to brackets

try to do that:



line = "a == 1"
for (i = 2; i<=5;i++){
line += " || a == " + i;
// i added this line below, to check what
//the 'line' var becomes
trace(line)
}

a = 1;
if (line) {
trace("works")
}