Can I verify a file exists before I LoadImage()?

BlitzMax Forums/BlitzMax Beginners Area/Can I verify a file exists before I LoadImage()?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hmmm... Will that work, Byteemoz?

I mean, the whole reason I wanted to check that the file exists FIRST is because loading a file that doesn't exist seemed to crash the game.

Anyway, I can tell you didn't run your code because your function is written to accept 3 variables, and your call to the function only uses one long string. :P

(I had the same idea, though, after I posted. :P )

Here's what I've got currently:

Function dynamicLoadImage:TImage(imageString:String)
  Local image:TImage
  If FileType(imageString)=1 Then
    image = LoadImage(imageString)
  Else
    image = LoadImage("graphics\null.png")
  EndIf 
  Return image
End Function

Local BackgroundImage:TImage
BackgroundImage = dynamicLoadImage("graphics\stage" + Level + ".png")


I guess I'll try it your way and see if it works. It does seem more direct. I'm just worried about causing another Unhandled Memory Exception!