if (something) #do a bunch of stuff
firstif = TRUE
end
if (somethingelse && firstif)
the above always fails since the second if doesn’t see firstif)
#do other stuff that is dependent on the first bunch of stuff
firstif = FALSE
end
Set your firstIf variable to a sentinel before running either if.
I.e., set it to false, then only if your first if statement passes,
will the second one be run.
if (something) #do a bunch of stuff
firstif = TRUE
end
if (somethingelse && firstif)
the above always fails since the second if doesn’t see firstif)
#do other stuff that is dependent on the first bunch of stuff
firstif = FALSE
end
Two ways to do this. First way:
if (something) #do a bunch of stuff
if (somethingelse) #do more stuff
end
end
If you can’t just nest them for one reason or another, here is
another way:
firstif
if (something) #do a bunch of stuff
firstif = true
end
if (somethingelse && firstif)
# the above always fails since the second if doesn’t see firstif) #do other stuff that is dependent on the first bunch of stuff
firstif = false
end
Notice that mentioning the variable outside of the scope makes it
available to both ifs.
Set your firstIf variable to a sentinel before running either if.
I.e., set it to false, then only if your first if statement passes,
will the second one be run.