nested ifs

Dave Cragg dcragg at lacscentre.co.uk
Wed Jan 25 12:21:06 EST 2006


On 25 Jan 2006, at 10:32, Chipp Walters wrote:

> 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, so I'm  
> forced to do:

The problem seems to occur before an "else" line.

If x > y then
   doSomething1
   if a = be then doSomething2 ##problem here
else
   doSomethng3
end if


I've always assumed (without any deep investigation) that it was a  
result of the engine's tolerance of various "if" constructions. For  
example the following compiles:

  if 1 > 2 then put 2
  else put 1

While we're on the subject, could someone who likes to use the "then  
on the following line" syntax please explain the advantages. I've  
always found it confusing when I come across it, but  there must be a  
reason for using it that I haven't yet grasped.

Cheers
Dave



More information about the use-livecode mailing list