newFileNamed (how to handle the cancel option?)

Ned Konz ned at squeakland.org
Tue Jan 18 22:44:34 UTC 2005


On Monday 17 January 2005 5:34 am, chenais wrote:
> I could manage in my software the cases: File exist and File doesn't exist,
> but is there not a simple way to define the behaviour of the (3) cancel
> option?

The default handling for FileExistsException does, as you note, raise an error 
on cancel.

Assuming that you want to use the existing menu, we can add a different 
exception handler and get something like the attached CS. This will return a 
file stream or nil if they chose cancel.

It's rather ugly, because the errors can be recursive (the default handling 
calls newFileNamed: again).

-- 
Ned Konz
http://bike-nomad.com/squeak/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NewFileOrNil-nk.1.cs
Type: text/x-c++src
Size: 1283 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20050118/08655bd4/NewFileOrNil-nk.1.cc


More information about the Squeak-dev mailing list