IF....

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
dazmanaz
Posts: 3
Joined: Wed Sep 14, 2011 3:12 pm

IF....

Post by dazmanaz » Fri Sep 16, 2011 4:49 pm

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

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: IF....

Post by Klaus » Fri Sep 16, 2011 4:59 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: IF....

Post by dunbarx » Fri Sep 16, 2011 5:17 pm

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

dazmanaz
Posts: 3
Joined: Wed Sep 14, 2011 3:12 pm

Re: IF....

Post by dazmanaz » Sat Sep 17, 2011 1:15 pm

Great! Thankyou both :D

Post Reply