File Exists?

If your program uses data files you will need to load and save them. Before doing either operation though, it is best to check that the file you want actually exists.

The Exist() function does this and if you pass it a filename it will tell you (true or false) whether it exists. An If statement can then take the appropriate action.

A point worth mentioning is that to create a file with a space in the name you have to add quotes to the string like this: a$=chr$(34)+"c:\My File"+chr$(34). But the Exist() function won't work if you add quotes. Confusing!

PROC exists:
Local a$(255)
a$="c:\My File"
If Exist(a$)
  Print "File exists"
  Print "File doesn't exist"

RAW Computing home page

  Psion home page