if then else

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: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
ThomasBodetti
Posts: 16
Joined: Tue May 14, 2013 12:30 pm

if then else

Post by ThomasBodetti » Fri Aug 09, 2013 11:35 pm

I have a stack that posts to a webserver and receives a result, if the result is OK:0 it means that the post connected but no action was taken, in that case I would want to exit to top with a message, letting the user know that something went wrong.

Code: Select all

 if fld "result1" contains "OK:0" then exit to top with answer "No messages were sent if using topics check spelling" 
I get an error, I know back a few years ago you used to be able to exit with message, but I dont see any docs on that or I missed it.

When everything goes Ok, then a normal result would be something like this, OK:145 or OK:458 up to 1000

I could use ":" as a delimiter, and run the second term and out put it as number of actions taken, but if its OK:0 then I need to stop the script from running, and tell the user some message.

Any thoughts or suggestions are welcomed and appreciated

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6672
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: if then else

Post by FourthWorld » Sat Aug 10, 2013 12:32 am

I'm not familiar with an option to send a message with "exit" (though it would be handy). But you can do what you need by breaking it into two lines:

Code: Select all

if fld "result1" contains "OK:0" then
   answer "No messages were sent if using topics check spelling" 
   exit to top
end if
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

ThomasBodetti
Posts: 16
Joined: Tue May 14, 2013 12:30 pm

Re: if then else

Post by ThomasBodetti » Sat Aug 10, 2013 12:39 am

Ok, yes, thanks, I had an old script I think back around 2.8.1

But its probably been changed years ago, yes, it would be handy, I used to use it to communicate an error, for a validation of a PHP script, but its been a long time since I have fooled with the engine at all.

The docs dont seem to be current with the latest version, I guess I need to read some more on this.

Thanks for the reply, )

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6672
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: if then else

Post by FourthWorld » Sat Aug 10, 2013 12:43 am

ThomasBodetti wrote:The docs dont seem to be current with the latest version, I guess I need to read some more on this.
I reviewed the Dictionary entry for "exit to top" before replying, and they seem to be current in that there's no mention of being able to use an additional command, consistent with the engine's having thrown an error when you tried.

What did you find inconsistent in the Dictionary vs. current engine behavior?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

reelstuff
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 254
Joined: Mon Apr 16, 2007 12:06 am
Location: USA
Contact:

Re: if then else

Post by reelstuff » Sat Aug 10, 2013 3:34 am

I sort of agree, on how the documentation is done like a cookie cutter template, when it should be more explanative.

Not inconsistant just light on common usage, the docs seem to have a consistent theme of providing less than useful information.

for example in 6.0.2 dictionary, but I do see some new data in there so they must be up to making some changes, it just seems like every time I look at the docs, there are no useful objective information, I know there is no comparison, but when I need to look up a PHP function, I can get all the information I need to make it happen, but this dictionary thing is like reading stereo instructions in braille.

Snip, bad example, but does demonstrate that some of the stuff in the dictionary and in the PDF are old and out of date, but I do think that if LC would update the documentation with an industry standard approach marketing this product would become much more easy.

just saying.
Last edited by reelstuff on Sat Aug 10, 2013 1:11 pm, edited 2 times in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 6672
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: if then else

Post by FourthWorld » Sat Aug 10, 2013 5:07 am

The userModify property seems another fairly good example for RunRev: it's HyperCard-specific, has no functional purpose in LC, I've never seen anyone even attempt to use it in my 15 years with LC, and yet they provided it for the benefit of a handful of people porting old HyperCard stacks and documented it far more thoroughly than anyone I know has ever needed. :)

Were you looking for info on tokens related to modifiability of stacks?
Richard Gaskin
Community volunteer LiveCode Community Liaison

LiveCode development, training, and consulting services: Fourth World Systems: http://FourthWorld.com
LiveCode User Group on Facebook : http://FaceBook.com/groups/LiveCodeUsers/

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”