Sorry to be so out of date but I am upgrading and compling (Quick64) some GWbasic programs to run on 64bit machines. I need to find the presence or absence of a file. In a batch file it would program something like this ..., but I want this to execute within GWBasic.

If exist c:\progA then goto A else B
:A do something
:B do something else

Thanks for any help

Use error trapping with an error-handling routine: ERR code 53 [file not found], but you should account for pathname and disk errors : 70 [Disc access denied] and 71 [Disc is not ready]; also 55, 72, 75, 76 can pull you up - check the GWBasic error codes [Gurgle them]. If you don't pay attention to these other error possibilities then... well, computers are unforgiving.
So, set up your error handler, then open and close the file to test it..

ON ERROR GOTO errorfileopen 'enables the error handler errorfileopen
OPEN C:ProgA for INPUT as #1 'tests you can actually read the file
CLOSE
ON ERROR GOTO 0 'terminates the error handler

errorfileopen:
'here you would use SELECT CASE ERR [I prefer this] or a simple IF THEN [ELSE] statement: [IF ERR=53 THEN ... ELSE ....]
RESUME 'takes you back to the CLOSE statement

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.