March 28, 2024, 03:00:42 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


OpenFile() bug?

Started by Bruce Peaslee, October 02, 2006, 04:49:24 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Bruce Peaslee

This doesn't catch the fact that there is no file:


f = OpenFile(sFileName, MODE_READ);
ÂÃ,  ÂÃ, if(f)
ÂÃ,  ÂÃ, {
ÂÃ,  ÂÃ,  ÂÃ,  proceed
ÂÃ,  ÂÃ, }
ÂÃ,  ÂÃ, else
ÂÃ,  ÂÃ, {
ÂÃ,  ÂÃ,  ÂÃ,  error message
ÂÃ,  ÂÃ, }


Am I doing this right or is there a problem with OpenFile()?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

LarryMc

is f declared as an unsigned int?
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Bruce Peaslee

Quote from: Larry McCaughn on October 02, 2006, 04:53:27 PM
is f declared as an unsigned int?

No, but I changed it and it made no difference. (It is shown as unsigned int in fileio.inc)
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

ExMember001

just played a bit with openfile..
if you change:
if (f)
to:
if (f = 1)
it works.

but if i use :
if (f <> 0) of if (f)
it doesnt work

Parker

I use that to check existance of files too :-\

However, the other check I use is
if( getfilelength( f ) > 0 )
{
    /* read... */
}
else
{
    /* error */
}

Ionic Wind Support Team

No, just not documented well yet.  OpenFile returns and invalid handle value on error.  0xFFFFFFFF or -1 int.

Ionic Wind Support Team

Bruce Peaslee

Quote from: Paul Turley on October 02, 2006, 06:48:29 PM
No, just not documented well yet.ÂÃ,  OpenFile returns and invalid handle value on error.ÂÃ,  0xFFFFFFFF or -1 int.

This works. But is there some way to get the specific error?
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

Windows API function GetLastError should do it.
Ionic Wind Support Team

Ionic Wind Support Team

I am changing the OpenFile function to return 0 on error.  Which is more consistant with other library functions.
Ionic Wind Support Team