nested ifs
Rob Cozens
rcozens at pon.net
Thu Jan 26 11:14:33 EST 2006
Hi Chipp,
>I like to do the following:
>
>if tResult is "Error" then
> answer "Go Ahead anyway" with "Cancel" or "OK"
> if it is "Cancel" then exit to top
>end if
>
>Most of the time it compiles, but sometimes the single line if
>statement in the middle throws and error and won't compile
I, like others, have encountered such errors; however in my case it
is _always_ caused by an imbalance of "ifs" & "end ifs" in my
handler, not the compiler having an off day.
A one-line if ("if" a = b then doSomething2") placed _immediately_
before an "else" that applies to a different "if" (in this example,
"if x> y then") will cause the compiler to choke.
Drawing on Brian's example, but scripted as I might
If x > y then
doSomething1
if a = b then doSomething2
else doSomething3
fails; but
If x > y then
doSomething1
if a = b then
doSomething2
end if
else doSomething3
and
If x > y then
doSomething1
if a = b then doSomething2
doSomethingElse -- whether or not a = b
else doSomething3
both will compile.
Rob Cozens CCW
Serendipity Software Company
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list