Page 1 of 1

IF....

Posted: Fri Sep 16, 2011 4:49 pm
by dazmanaz
Hello All,

I was wondering if it is possbile to have an IF statement within an IF statement; IF-ception if you will.
Any replies or alternative suggestions would be appreciated :)

Thanks,

Daz

Re: IF....

Posted: Fri Sep 16, 2011 4:59 pm
by Klaus
Hi Daz,

sure this is possible! :D

Code: Select all

...
## Pseudocode!
if today = "Saturday" then
   if the time > 7_PM then
      go_to_the_cinemas
   else
     visit_the_zoo
     bring_the_kids
  end if
end if
...
8)


Best

Klaus

Re: IF....

Posted: Fri Sep 16, 2011 5:17 pm
by dunbarx
Do you mean something like this:

Code: Select all

on mouseup
   if 4 = 4 then
      if 5=6 then
         answer "Uh,oh, math is not working"
      else answer "whew, math is still OK"
   end if   
end mouseup
There are almost no limits to the way you can nest "if" structures. Check the dictionary. There are many allowed forms, and these can be mixed and matched at will.

I can tell you, though, start off simply; it is possible to get mired with very complex structures, and it is usually better to use several simpler ones than a single huge horror. Readability (and writability) frequently trumps brevity.

Craig Newman

Re: IF....

Posted: Sat Sep 17, 2011 1:15 pm
by dazmanaz
Great! Thankyou both :D