[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unwind-protect&choose-file-dia
- To: KHOSLA@AppleLink.Apple.COM (Khosla Consulting, Ashok Khosla,PAS), INFO-MCL@CAMBRIDGE.APPLE.COM
- Subject: Re: unwind-protect&choose-file-dia
- From: straz (Steve Strassmann)
- Date: Tue, 23 Aug 1994 13:58:47 -0400
At 4:57 AM 8/23/94 +0000, KHOSLA@AppleLink.Apple.COM (Khosla Consulting, Ashok Khosla,PAS wrote:
>I'm having trouble getting the choose-file-dialog to work correctly when
>cancelled - Here is a sample:
>
>(progn (setf aFileName "Unnamed")
> (setf aFileName (unwind-protect
> (choose-file-dialog :mac-file-type :|TEXT|)
> "cancelled"))
> aFileName)
>
>When the SFGetFile appears, if I hit escape or cancel, the dialog unwinds past
>my unwind protect, and I never get aFileName set to "cancelled".
>
>
>Any ideas?
>
The Cancel button throws a :cancel tag, which isn't caught by anything
in your code, so it throws all the way to the top level listener.
The second setf never gets a chance to execute, since the "setf" itself
is not in the cleanup clause of your unwind-protect.
How about something like this instead?
(let ((name (catch :cancel
(choose-file-dialog :mac-file-type :|TEXT|))))
(setf aFileName (if (eq name :cancel)
"cancelled"
name)))