Page 1 of 1

Problem with the Cancel function

Posted: Sat Sep 25, 2010 2:58 pm
by Simon Knight
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.

Re: Problem with the Cancel function

Posted: Sat Sep 25, 2010 4:16 pm
by mwieder
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.

Re: Problem with the Cancel function

Posted: Sat Sep 25, 2010 7:09 pm
by Simon Knight
Thanks - obvious now its been pointed out.