realbasic-nug
[Top] [All Lists]

Re: Unhandled Exception Error assistance.

To: REALbasic Network Users Group <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Unhandled Exception Error assistance.
From: Frank Bitterlich <bitterlich at gsco dot de>
Date: Thu, 31 Jan 2002 14:40:51 +0100
Yes, you are indeed missing something essential (but not neccesary
obvious): Error checking.

The line
>   bs = f.CreateBinaryFile("jpeg")
is supposed to either create a file and return a BinaryStream; or fail
and return NIL.

In you case the latter happened.

You can never assume that the creation of a file will succed. There are
about thousand reasons why this can fail; most of them not under the
control of your application. So ALWAYS add NIL checking when creating a
file; better yet, ALWAYS add NIL checking when creating ANY object.

BTW, did you remember to create a file type "jpeg" in the "File Types"
dialog? Could be the reason. Remember, youÄre not supposed to give a
MacType or MacCreator to CreateBinaryFile, but rather tha name of a file
type record you have created.

Cheers,
   Frank+++



Web Masters iMac wrote:
> 
> Hi,
> 
> The following code generates an Unhandled Exception Error in bs.Write s
> 
> Synopsis: having opened a valid JPEG file and into String s I am now writing
> the resultant string back to a temporary file ready to be read in again and
> displayed (on a Canvas.backdrop ? other suggestion?)
...
>   f = GetFolderItem("temp.JPG")
>   if f.Exists then
>     f.Delete
>   end if
> 
>   bs = f.CreateBinaryFile("jpeg")
>   bs.Write s
>   bs.Close
> 
>   p = f.OpenAsPicture
...

--
Günter Schmidt & Co. oHG         
Frank Bitterlich             eMail: bitterlich at gsco dot de
Schlosserstr. 2-4            WWW:   http://www.gsco.de/gsco
D-60322 Frankfurt            Tel.:  069 / 156809-29
GERMANY                      Fax:   069 / 156809-28


<Prev in Thread] Current Thread [Next in Thread>