A curious case

J. Landman Gay jacque at hyperactivesw.com
Tue Mar 1 22:04:16 EST 2011


On 3/1/11 6:40 PM, Bob Sneidar wrote:
> Hi all.
>
> I just came across a curious issue where I had an if then else control structure inside another if then structure.
>
> I *thought* I used toe be able to use the form
>
> if statement then
>      -- do somestuff
> else if anotherstatement then
>      -- do someotherstuff
> else
>      -- do defaultstuff
> end if
>
> When I nested this inside another if then else control structure it told me I was missing an end if! However if I converted the above structure to a switch control structure the script compiled fine. Have I stumbled upon something here? It kind of makes sense to me because the compiler may be having trouble knowing which control structure *else if anotherstatement* belongs to.
>
> This is not a problem per se, but I am just curious and it may help someone else who encounters it in the future to not spend an hour or two poring over code that is technically correct but won't compile.
>
> Bob

It's a known issue when the compiler gets confused about which "else" 
goes with which. You can either rewrite the section using the long form, 
or put a carriage return after the last line of the embedded "end if". I 
tend to use the short if/else form a lot myself and I see this all the time.

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list