Re: Cancel dialog button doesn't cancel (FileMaker Pro)
Re: Cancel dialog button doesn't cancel (FileMaker Pro)
- Subject: Re: Cancel dialog button doesn't cancel (FileMaker Pro)
- From: Kai Edwards <email@hidden>
- Date: Thu, 20 Dec 2001 20:15:39 +0100
>
Date: Tue, 18 Dec 2001 17:18:15 -0800
>
From: Janis Rough <email@hidden>
>
To: "'AppleScript-Users'" <email@hidden>
>
Subject: cancel dialog button doesn't quit Filemaker pro
>
>
I thought if you hit the "cancel" button it cancels
>
the script or does it just cancel the dialog?
>
>
If (isempty(field))
>
perform applescript:
>
Try
>
set v to cell "g_vendor_id" of current record
>
set the user_choice to the button returned of the result
>
{display dialog "Do you wish to create a Lettershop P.O. for
>
Vendor ID#"&
>
" "& v&"?" default button 1 buttons {"okay","cancel "} with
>
icon 2}
>
end try
>
exit script
>
else
>
perform applescript:
>
Try
>
set v to cell "g_lettershop_id" of current record
>
set the user_choice to the button returned of the result
>
{display dialog "Do you wish to create a Lettershop P.O. for
>
Vendor ID#"&
>
" "& v&"?" default button 1 buttons {"okay","cancel "} with
>
icon 2}
>
end try
>
perform external subscript
>
end if
This may be, as has been suggested, a structural problem - but I suspect it
may have more to do with simple syntax.
If the script is pretty much as you've shown it, then all you need do to
effect a script cancellation is remove the white space at the end of the
word "cancel ".
Try replacing both lines that read:
>
set the user_choice to the button returned of the result
>
{display dialog "Do you wish to create a Lettershop P.O. for
>
Vendor ID#"&
>
" "& v&"?" default button 1 buttons {"okay","cancel "} with
>
icon 2}
with something like this:
set user_choice to button returned of (display dialog "Do you wish to create
a Lettershop P.O. for Vendor ID#" & space & v & "?" buttons {"OK", "Cancel"}
default button 1 with icon 2)
The reason for this is that AS recognises only "Cancel" (or "cancel") as an
instruction to exit the handler. Any white space added will be regarded as
another response. Of course, this can sometimes be quite useful if you want
to run some other routine when the user chooses a " Cancel " (rather than a
"Cancel") button.
If I'm off track about the problem here, let me know and I'll be happy to
look at it again.
(For example, if you really are trying to get the AS dialog to exit the FMP
script that called it, you will almost certainly need to return some
additional instructions.)
**********************************
BTW, you can also get FileMaker to do some homework before performing an
AppleScript routine - which can greatly simplify the AS side of things.
A calculation field, for instance, could decide whether the "g_vendor_id" or
the "g_lettershop_id" data should be used as v in your script - and even
define the entire AppleScript routine to be run. This would avoid most of
the repetition in your if/then statements. I won't bore you with the details
here, but let me know if you're interested in exploring this approach
further.
For the moment though, I hope the above helps.
--
**********************************
Kai Edwards Creative Resources
1 Compton Avenue Brighton UK
Telephone +44 (0)1273 326810
**********************************