When LoadTerrain, and LoadTexture Fail.

Blitz3D Forums/Blitz3D Beginners Area/When LoadTerrain, and LoadTexture Fail.

Wrath_of_Zeus(Posted 2003) [#1]
Do they give an error message? I would like to check to make sure they worked, then throw a usefull error message before jumping out of the program.

So first I need to know if they just fail if a bad file is sent, then I need to know how to pop up an error message.

I can probably find the error message thing on my own, but the docs that came with the engine don't mention if the Loads return any kind of failure message.


GfK(Posted 2003) [#2]
texture = LoadTexture("mytexture.png")
If texture = 0
  RuntimeError "Texture not loaded!"
EndIf



Wrath_of_Zeus(Posted 2003) [#3]
Much appreciated


Wrath_of_Zeus(Posted 2003) [#4]
It would also be nice if I could only throw up the error if in debug mode, or throw up different errors if in debug. is there an equivalent to ifdef or ifndef?


WolRon(Posted 2003) [#5]
Const Debug = True

If Debug Then
  ;Do whatever you want
EndIf


Not sure if there are IfDef or IfNotDef directives but this bit of code would amount to the exact same thing.

Also, I've heard, but not tested, that when writing an If statement such as above, the If statement will not be included in the executable if the constant variable Debug is set to false. In other words, your release version won't be cluttered with any of your debugging checks (thereby increasing efficiency).