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.

Woot. Wrapped it all up in a nice clean function I can call from anywhere within my program with just one line. :)

'This code is public domain, yada yada yada.

'Tries to load an image at runtime, uses a default image if none exists.
'Note: if default image does not exist, the app still crashes!
'This was not meant as a crashfix, but as a placeholder for missing art assets during game development!

Function dynamicLoadImage:TImage(prefix:String="", n:Int=0,suffix:String="")
  Local image:TImage
    ' Load in the required Images...
    'Ensure backgroundImage exists before loading.
    Local sFileName:String=prefix+n+suffix 
    Print sFileName
    If FileType(sFileName)=1 Then
      image = LoadImage(sFileName)
    Else
      image = LoadImage("graphics\null.png")
    EndIf 
    Return image
End Function


'Example of usage
Local BackgroundImage:TImage
BackgroundImage = dynamicLoadImage("graphics\stage", Level,".png")

Think this is worth adding to the code archive? It certianly was exactly what I was looking for. :)