[Implemented] Error result for CreateImage()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

[Implemented] Error result for CreateImage()

Post by Mistrel »

From what I can tell from the documentation, CreateImage has no error result if the image creation fails (e.g. not enough memory). For reliable error catching I would like to see this added.

For example, the function can return -1 on an error.
User avatar
Arctic Fox
Enthusiast
Enthusiast
Posts: 609
Joined: Sun Dec 21, 2008 5:02 pm
Location: Aarhus, Denmark

Post by Arctic Fox »

Isn't it just returning 0 when encountering an error or have I misunderstood something?
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

Returning 0 would work too. My point is there's nothing in the documentation that identifies what it returns if it returns anything on an error. Or if it just crashes the program.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Error result for CreateImage()

Post by PB »

I think the docs just need that added. It returns 0 if no image can be created:

Code: Select all

Debug CreateImage(0,9999,9999) ; Returns 0
However, I also notice that the debugger returns a runtime error if width or
height is >32000 pixels, which is in contradiction to the docs which state the
max is 8192 for width and height:

Code: Select all

Debug CreateImage(0,99999,99999) ; Compiler message about >32000 pixels
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

PB, you correctly state that it's an error thrown by the debugger but mention that it's a compiler error in your comment.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

No, one returns 0 and one is an error. So only one is an error.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Post by Mistrel »

What I mean is that you're using both "debugger error" and "compiler error" in your description. These are contradictory because if it's a compiler error then the debugger is never run.
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Post by PB »

I don't know. I'm tired. Wait for someone else to contribute.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
freak
PureBasic Team
PureBasic Team
Posts: 5940
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

All object creation functions in PB return 0 on failure.
quidquid Latine dictum sit altum videtur
Post Reply