Problem with the Cancel function

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
Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Problem with the Cancel function

Post by Simon Knight » Sat Sep 25, 2010 2:58 pm

I have some code that is not working as expected. I have read the dictionary and copied the relevant part below:

From the dictionary entry for answer file:
The absolute file path of the file the user chose is placed in the it variable. If the answer files form is used, a return-delimited list of such paths is placed in the it variable. If the user cancels the dialog, the it variable is set to empty, and the result function returns "Cancel".

So I added the following code with a trap for when the user presses cancel:

Code: Select all

-Prompt for input file
   answer file "Select the TAB file that describes the" & pListName & " init data" with type "Text|txt"
   --? this next line does not work
   if the result is "Cancel" then exit LoadDescriptionFile 
I was expecting the result to be set to Cancel when the user selects Cancel but I think that it is being left blank or I am not using the result function correctly. I know I can use the value in "it" as a check but I was wondering where I went wrong.
best wishes
Skids

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Re: Problem with the Cancel function

Post by mwieder » Sat Sep 25, 2010 4:16 pm

You're specifying a file type in your "answer file" command. According to the docs
If types are specified, the result function will return the tag of the corresponding type selected from the supplied drop-down list.
so if the user selects a file the result will contain "Text"; the result will be empty on Cancel.

Simon Knight
Posts: 919
Joined: Wed Nov 04, 2009 11:41 am

Re: Problem with the Cancel function

Post by Simon Knight » Sat Sep 25, 2010 7:09 pm

Thanks - obvious now its been pointed out.
best wishes
Skids

Post Reply