1 (edited by Luzie 2023-04-13 15:54:08)

Topic: Request for a DOT-Command to report if file or directory exist

Here´s my request for a DOT-Command e.g. called ".ifexist" to report if file or directory exists.

I need it under NextBASIC, and there´s no BASIC built-in command for doing this query from NextBASIC yet.

Thank you!

2

Re: Request for a DOT-Command to report if file or directory exist

I'm fairly sure Garry's version of 128 BASIC has some kind of error handling equivalent to ON ERROR that you could use for that purpose.

3

Re: Request for a DOT-Command to report if file or directory exist

aowen wrote:

I'm fairly sure Garry's version of 128 BASIC has some kind of error handling equivalent to ON ERROR that you could use for that purpose.

Thank you. Someone tells me a way in NextBASIC (using ON ERROR) to check for existance of a file or directory.

4 (edited by aowen 2023-07-24 16:54:44)

Re: Request for a DOT-Command to report if file or directory exist

Luzie wrote:
aowen wrote:

I'm fairly sure Garry's version of 128 BASIC has some kind of error handling equivalent to ON ERROR that you could use for that purpose.

Thank you. Someone tells me a way in NextBASIC (using ON ERROR) to check for existance of a file or directory.

Sorry no-one has got back to you on this. Here's how I'd do it in SE Basic IV.

10 EXISTS = 1
20 FOLDER$ = "FOLDER"
30 ON ERROR GOSUB 100
40 CHDIR FOLDER$
50 IF EXISTS = 1 THEN PRINT "Folder exists": ELSE PRINT "Folder does not exist"
60 END
100 ON ERROR STOP
110 EXISTS = 0
120 RETURN

5 (edited by SZERMAN 2024-09-30 16:24:58)

Re: Request for a DOT-Command to report if file or directory exist

CHDir not a valid Next dot command or direct command

This will work though

5 Folder$="games\mygear"
10 r$="Directory found"
20 on error r$="Not found": goto %50
40 CD Folder$
50 Print r$: on error

If you wish to confirm if a file exists I found the best method is using the dot command .filesize
.filesize myfile

This puts the file size in variable T.  If no file existing T=0
This command isn't in the distro you have to add it to the dot directory to use