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.

Try something like this to check the file exists before you try to load it:-

local sFileName:string="graphics\stage"+Level+".png"

  if filetype(sFileName)=1 then
     BackgroundImage = LoadImage(sFileName)
  else
     BackgroundImage = LoadImage("stage1.png")
  endif 


or you could just do this, which will cover you if the file exists but does not load correctly:-

local sFileName:string="graphics\stage"+Level+".png"

  BackgroundImage = LoadImage(sFileName)
  
  if not BackgroundImage then
     BackgroundImage = LoadImage("stage1.png")
  endif 


Steve.