If then else in handlers *Q*

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
istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

If then else in handlers *Q*

Post by istech » Sun Jan 19, 2014 1:04 pm

Hi all,

I have a question about handlers and if conditions. I hope you can help.

I have a handler with several if conditions in them and then more code after the statements.

At the moment if one of the if condition is true the rest of the script is not run/executed even after I have closed the if structure why is this?

example:
on OpenCard
if condition
then
do something
end if

if condition2
then
do something else
end if

##extra code to do other things below does not get executed if 1 condition is true. If I put it before the "if" all work. Just want to learn why it does not if put after. I hope this makes sense.
animations##not executing
launch web pages##not executing
end OpenCard

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

Re: If then else in handlers *Q*

Post by Klaus » Sun Jan 19, 2014 1:36 pm

Hi istech,

it should work, unless "do something" or "do something else" somehow EXITs all remaining commands!
Could you please post these scripts or parts of them?


Best

Klaus

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: If then else in handlers *Q*

Post by istech » Sun Jan 19, 2014 1:52 pm

on opencard
## AutoReader
if the label of btn "RTM" is "ON"
then
RTMOn
end if
if the label of btn "RTM" is "OFF"
then
RTMOff
end if
## show image
wait for 2 seconds with messages## Could this be the problem
show image "MMLk" with visual effect dissolve## not executing
MakeMagic1## not executing
MakeMagic2## not executing
end opencard

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

Re: If then else in handlers *Q*

Post by Klaus » Sun Jan 19, 2014 2:03 pm

Hi istech,

come on, how shall I know what RTMon/off do? 8)

Here a slightly more effective "if then":

Code: Select all

...
if the label of btn "RTM" = "ON" then
   RTMOn
ELSE
   RTMOff
end if
...
And please use the new "visual effect" syntax, maybe that is also a problem:
...
lock screen for visual effect
show image "MMLk"
unlock screen with visual effect dissolve
...

WAIT should not be a problem at all here.


Best

Klaus

istech
Posts: 211
Joined: Thu Sep 19, 2013 10:08 am

Re: If then else in handlers *Q*

Post by istech » Sun Jan 19, 2014 3:04 pm

Thanks Klaus - 8)

Any help with the code is much appreciated and improvements/tips just throw them my way. :wink:

My script is not finished yet and this stopped working as I was testing. So I started to scratch my head

as in my head it should work. :lol: I will restart and remove any extra code and post what is finished

and do some more digging thanks again Klaus....(and as I am typing this I found a bug in a server call)

Which I now fixed and it is working now. :oops: That's 2 hours out of my life I can never get back. :lol:

Thanks again Klaus - Still always learning - I am getting there slowly. :mrgreen:

Post Reply