Quit a Script in the middle?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
no1g8tor
Posts: 62
Joined: Fri Nov 23, 2007 3:01 pm

Quit a Script in the middle?

Post by no1g8tor » Tue Apr 15, 2008 5:20 pm

I have a script that calls other scripts.

The first thing the script does is bring up a File dialog box and prompts for a file.

If the User clicks "cancel" then I need the progam to go back to the "Home" card and stop the remainder scripts.

I did use...
answer file "Select a file:" with type "html|htm|html"
if it is "Cancel" then go visible to card "dog1" of stack "race1"
exit to top

if it <> "" then
put url ("file:" & it) into tData
end if

If I Click "cancel" it still continues with the the rest of the script.

Please help as if the user does not choose a file it screws up all the data.

Thank you

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

Post by Klaus » Tue Apr 15, 2008 5:26 pm

Hi user with the strange nick,

...
go VISIBLE...???
...

I wonder why this does not throw an error :-)

OK, try this:

Code: Select all

on mouseup
  answer file "Select a file:" with type "html|htm|html" 
  if it = "Cancel" then 
      go card "dog1" of stack "race1" 
      exit mouseup
     ## Here you can put the name of the handler you want to exit like "mouseup“ in this case...
  end if 
  ...
end mouseup

Best

Klaus

no1g8tor
Posts: 62
Joined: Fri Nov 23, 2007 3:01 pm

Post by no1g8tor » Mon Apr 21, 2008 2:45 pm

Sorry for not getting back sooner...This did not work. It alway continues and just to check I put in the answer command and it comes up if you push cancel or not? Please Help.

on mouseup
answer file "Select a file:" with type "html|htm|html"
if it is "Cancel" then
go to cd "trackdata" of stack "trackdata"
exit mouseup
## Here you can put the name of the handler you want to exit like "mouseup in this case...
else
answer "you did it"
end if

end mouseup

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Mon Apr 21, 2008 4:06 pm

It won't contain "cancel" for the "answer file with type" form (Most likely Klaus confused it with the older "answer file with filter" type (but even then the result, and not it would contain "cancel")).

If you had read the documentation, then you would know that the it Variable will be empty if you press cancel, so just change the if like this:

Code: Select all

on mouseup 
  answer file "Select a file:" with type "html|htm|html" 
  if it = "" then 
      go card "dog1" of stack "race1" 
      exit mouseup 
     ## Here you can put the name of the handler you want to exit like "mouseup“ in this case... 
  end if 
  ... 
end mouseup
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

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

Post by Klaus » Mon Apr 21, 2008 5:39 pm

Hi all,

oops, yes Björnke is right I must have mixed it with some other "it/result" :-/

Sorry for the confusion.

And yes, always checking the docs is not a bad idea! ;-)

no1g8tor
Posts: 62
Joined: Fri Nov 23, 2007 3:01 pm

Post by no1g8tor » Sun Apr 27, 2008 7:54 pm

Well first of all I did read the docs and it does not tell everything or this Forum would be a waist of time.

I appreciate that we have this and thank everyone who contributes to it.

Thanks for all the help and I had to use the exit to top to quit the calling handler.

Thanks again and keep up the great work.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Mon Apr 28, 2008 11:48 am

no1g8tor wrote:Well first of all I did read the docs and it does not tell everything or this Forum would be a waist of time.
I oppose this. The documentation contains everything about every comand in Rev (if not then it's a bug). However that information is too wealthy, and most people get overwhelmed.

So the forum and the use list are mostly for cases that are more general (like what repeat loop to use when, when to use arrays or cprops, etc.), or for people who missed the important bit in the docu due to information overload.

Of course the documentation approachability could need some heavy spicing up, but it's information content is complete.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

keyless
Posts: 211
Joined: Wed Dec 12, 2007 11:21 pm

Post by keyless » Mon Apr 28, 2008 11:38 pm

BvG wrote:
no1g8tor wrote:Well first of all I did read the docs and it does not tell everything or this Forum would be a waist of time.
I oppose this. The documentation contains everything about every comand in Rev (if not then it's a bug). However that information is too wealthy, and most people get overwhelmed.

So the forum and the use list are mostly for cases that are more general (like what repeat loop to use when, when to use arrays or cprops, etc.), or for people who missed the important bit in the docu due to information overload.

Of course the documentation approachability could need some heavy spicing up, but it's information content is complete.
Its its approachability that makes it useless in a lot of simple cases. Lets say I was using a checkbox for the first time. You'd think I just had to type check box into the Dictionary, especially since it is an object of the tools. But you get nothing, but a description of checkmark. Your expected to somehow stubble apon autohilite before you get any incling of how to use checkbox. I'd call that incomplete.

no1g8tor
Posts: 62
Joined: Fri Nov 23, 2007 3:01 pm

Post by no1g8tor » Tue Apr 29, 2008 6:12 pm

Maybe I was wrong. I was speaking of the "User Guide". Is there a better documentation I am missing.

Unless you know exactly what you are looking for the "A-Z" guide is useles. I wish the online docs were broken down in to categories where you could see a list of say Text and File System and it would list the commands and when you click the command it would give the description and examples like it does now.

Maybe I am wrong, just my 2 cents.

Thanks again

no1g8tor
Posts: 62
Joined: Fri Nov 23, 2007 3:01 pm

Post by no1g8tor » Fri May 02, 2008 1:22 am

another question about the same subject.

When I try to use the same code to cancel a print command it does not work. IT just continues and prints anyway?

Thanks

ie...


answer printer
if it = "" then
go card "Home" of stack "Finishline 8.0"
exit to top
end if

answer printer
if it = "cancel" then
go card "Home" of stack "Finishline 8.0"
exit to top
end if

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

Post by Klaus » Fri May 02, 2008 11:28 am

Hi,

hmmm, this is the last line of the "answer printer" entry in the docs:
...
Note: If the user clicks the cancel button of the answer printer dialog, then "cancel" is put into the result.
Unless you know exactly what you are looking for the "A-Z" guide is useles.
C'mon guys, please show a tiny bit more of good will, thanks!

no1g8tor
Posts: 62
Joined: Fri Nov 23, 2007 3:01 pm

Post by no1g8tor » Sun May 04, 2008 5:20 am

Klaus,

Thank you for pointing that out. Then why does it NOT work? I provided the code in the previous post and if the "GREAT DOCS" are correct then it should work. When I push "Cancel", it continues to print. I also have a lot of questions concerning printing in general and will leave it for another post.

Please let me know what I am doing wrong. It would be very appreciated.

There is plenty of good will on here and most of us, including me are thankful to the people who make positive useful comments and not try to show people up with putting things in there face.

I think that the docs are good but just not as good as they could be or could be better organized. If I remember correctly, in an earlier version they had the docs organized by type, but I may be wrong. A to Z does not help someone who is looking for say a Text function and has to guess where to look.

There is a "COPYCAT" language on the net that is now freeware called HyperNext Studio" and I took a look at it and it is slow and not even close to this,but I liked the Help Docs and the way they are layed out. Check it out and see if you agree?

The nice people at Revolution know that its not perfect and are always working to make things better and that is why I am so attracted to this programming format. I also think they like comments from the end user to understand what we are in need of.

I see you do help people out on here a lot and to all of us that you have helped we thank you. Just be nice.

My opinion counts because I paid my $400 for the software and know that I am just as important as everyone who is a revolution customer.

Please if you can help me respond.

Thanks again to everyone.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Sun May 04, 2008 9:57 am

it is not the same as the result.

Klaus thinks that distinction is very simple to understand, but actually it's not explained anywhere in the online documentation (maybe it's somewhere hidden in the pdf?). When I started to read about the result, first I never understood where that result would end up. Of course the command results in something, but where would it put the produced result? One of the back draws of using such an English like language I guess.

I also remember having problems to understand which command puts stuff in the result, and which uses it. In the end I had to come to the conclusion that there's no rule about which is used, and whenever a command uses them, I have to look up the dictionary entries to know for sure which will actually contain a reply for me to use.

You can query the result like this:

Code: Select all

on mouseUp
  answer printer 
  if the result = "cancel" then 
    go card "Home" of stack "Finishline 8.0" 
    exit to top
  end if
end mouseUp
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

no1g8tor
Posts: 62
Joined: Fri Nov 23, 2007 3:01 pm

Post by no1g8tor » Wed May 07, 2008 2:39 am

It is working perfect now and I would like to thank everyone who helped and keep up the great work. This is what what keeps this a strong platform.

Post Reply