DOESFILEEXIST()

Previous topic - Next topic

Hemlos

Code (glbasic) Select
ok=DOESFILEEXIST(FileName$)
PRINT ok,10,10
SHOWSCREEN
MOUSEWAIT


if my FileName$ is Particle.png then it will return 1

if the FileName$ is Particle2.png then it will return 0

Both files are properly named, and exist in the correct directory.

It seems the problem is: when a number is in the filename, it wont find the file.

Bing ChatGpt is pretty smart :O

Ian Price

Sorry, but it does work (in V6.248 anyway) - my Balloonacy game uses numbers in the data files for loading.

My exact (and working code)
Code (glbasic) Select

FUNCTION load_data:
LOCAL file$="media/data/b"+lvl+".dat"

LOCAL ok=DOESFILEEXIST(file$)

LOCAL n%

IF ok

OPENFILE (1,file$,TRUE)

FOR y=0 TO 23
FOR x=0 TO 39
  READBYTE 1, n
  map[x][y]=n
NEXT
NEXT

CLOSEFILE 1

ENDIF
ENDFUNCTION


It certainly works with data, not checked with images.
I came. I saw. I played.

MrTAToad

#2
Dont forget all images need to be in the .app directory (or at least in a directory from that)

It does works fine with images - with and without numbers in them :)

Hemlos

#3
Sorry, in Version 7.057
The SpriteZ API error checking mode made me aware of it.

I researched all possible ways to cause this error....everything is named, placed, and declared perfectly.
So, I made a test program(top of this topic), and tested it a dozen times.
I found that, if a number is in the filename(in middle, or at the end, or anywhere in the name)...
...it returns zero.  :x
Bing ChatGpt is pretty smart :O

Moru

You might want to upgrade to the latest version before testing bugs: 7.061
I tested your code and it works perfectly on my computer.

MrTAToad

Are you running this on a Windows machine (case-insensitive filenames) or Mac/Linux (case-sensitive) ?

Hemlos

#6
Quote from: MrTAToad on 2009-Aug-02
Dont forget all images need to be in the .app directory (or at least in a directory from that)

It does works fine with images - with and without numbers in them :)


sigh....yup this is it....i am not used to this extra directory.
I have 2 data directories lol.

Thank you all, for the help fellas, i was overlooking this, over and over again. :S
Bing ChatGpt is pretty smart :O

MrTAToad

We've all done that  :good: