0

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

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by gerbil
0

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

Edited by gerbil

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.