File operations : return specific errorcode

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
tomk
New User
New User
Posts: 5
Joined: Wed Jun 11, 2003 4:37 pm

File operations : return specific errorcode

Post by tomk »

Hi there,

I would love to have 2 things in file opeartions

1. returning defined errorcode
Fileoperations like open/create should return a defined errorvalue if something has gone wrong.
Like in some languages I use I get an :
error 5 : unable to open exclusive
Error 3 : Path not found

2. read/write return
read/write operations like readdata/writedata,.. should return the length read/written, so validation would be easier.

Greetings
tom
Pupil
Enthusiast
Enthusiast
Posts: 715
Joined: Fri Apr 25, 2003 3:56 pm

Re: File operations : return specific errorcode

Post by Pupil »

tomk wrote: 2. read/write return
read/write operations like readdata/writedata,.. should return the length read/written, so validation would be easier.
They already do(windows version atleast), problem is that the reference manual don't tell you that. So this would work nicely:

Code: Select all

length.l = ReadData(*buffer, 1024) ; where 'length' is the actual length that was read
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

About a specific error code:

On the Windows operating system, you can almost always get a code for
the last occured error, after a function has failed.

Code: Select all

ErrorCode.l = GetLastError_()
As I said, this is an universal function, and can be used after a failure of
lots of different commands.

Here you can find the meanings of the returned error codes:
http://msdn.microsoft.com/library/defau ... _codes.asp

Timo
quidquid Latine dictum sit altum videtur
tomk
New User
New User
Posts: 5
Joined: Wed Jun 11, 2003 4:37 pm

Post by tomk »

Hello ,

thanks for the info, so I have to correct my wish :

I would like to have a better online help :-)

Thanks again
tom
Post Reply