Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test if a directory exist in qbasic?

I'm writing a program in Qbasic. I'd like to know how to test if a folder exists.

The idea is:

IF "c:\user\basic\blablabla\" exists (?? how to programm the "exist" test?)
THEN CHDIR "c:\user\basic\blablabla\"
ELSE 
MKDIR "c:\user\basic\blablabla\"
CHDIR "c:\user\basic\blablabla\"
ENDIF

I hope i'm clear enough,

thank you very much for your suggestions !

:)

like image 762
manny- Avatar asked Jan 01 '23 10:01

manny-


1 Answers

Try changing the directory to blablabla. If it doesn't exist, there'll be an error. Trap this error and specify an error handling routine.

ON ERROR GOTO doesnotexist
CHDIR "c:\user\basic\blablabla\"
END

doesnotexist:
MKDIR "c:\user\basic\blablabla\"
CHDIR "c:\user\basic\blablabla\"
RESUME NEXT
like image 58
Sardar Usama Avatar answered Jan 04 '23 08:01

Sardar Usama