Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.acorn.programmer > #5549

Re: Testing for the presence of a file

Subject Re: Testing for the presence of a file
Newsgroups comp.sys.acorn.programmer
From Alan Adams <alan@adamshome.org.uk>
Date 2018-10-08 14:24 +0100
Message-ID <c5cec84357.Alan.Adams@ArmX6.adamshome.org.uk> (permalink)
References <70cfbe4357.graham@graham.durain.uk> <3b32c04357.Alan.Adams@ArmX6.adamshome.org.uk> <5743c2acfdbob@sick-of-spam.invalid>
Organization Orpheus Internet Services

Show all headers | View raw


In message <5743c2acfdbob@sick-of-spam.invalid>
          Bob Latham <bob@sick-of-spam.invalid> wrote:

> In article <3b32c04357.Alan.Adams@ArmX6.adamshome.org.uk>,
>    Alan Adams <alan@adamshome.org.uk> wrote:
>> In message <70cfbe4357.graham@graham.durain.uk>
>>           Graham Pickles <graham@durain.uk> wrote:

>>> I'm having a senior moment!  What is the simplest method of determining
>>> in a Basic (RiscOs 4.02) program whether a named file exists in a
>>> particular directory?

>>> e.g. A file called test might/might not exist in my <Data$Dir>
>>> directory. If it exists then I wish to remove it but don't want to
>>> create an error if it doesn't exist!

>>> Regards to all,

>> X=OPENIN(TESTFILE$)
>> IF X=0 THEN
>>   PRINT "FILE "+TESTFILE$+" DOES NOT EXIST"
>> ELSE
>>   CLOSE#X
>>   PRINT "FILE "+TESTFILE$+" EXISTS"
>> ENDIF

> Okay, complication of "in Basic" but isn't "OS_File 17" the way to go
> with a bit of oscli perhaps?

And in the BASIC above, X=0 after the CLOSE, and near the start of the 
progrsamme
X=0
so that your error trap can include

IF X<>0 THEN CLOSE#X
without introducing an error into the error handler.

> Cheers,

> Bob.



-- 
Alan Adams, from Northamptonshire
alan@adamshome.org.uk
http://www.nckc.org.uk/

Back to comp.sys.acorn.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Testing for the presence of a file Graham Pickles <graham@durain.uk> - 2018-10-08 12:35 +0100
  Re: Testing for the presence of a file Alan Adams <alan@adamshome.org.uk> - 2018-10-08 12:50 +0100
    Re: Testing for the presence of a file Bob Latham <bob@sick-of-spam.invalid> - 2018-10-08 13:17 +0100
      Re: Testing for the presence of a file Alan Adams <alan@adamshome.org.uk> - 2018-10-08 14:24 +0100
      Re: Testing for the presence of a file Bob Latham <bob@sick-of-spam.invalid> - 2018-10-08 14:22 +0100
  Re: Testing for the presence of a file "John Williams (News)" <UCEbin@tiscali.co.uk> - 2018-10-08 14:42 +0100
    Re: Testing for the presence of a file Graham Pickles <graham@durain.uk> - 2018-10-09 09:33 +0100
      Re: Testing for the presence of a file "John Williams (News)" <UCEbin@tiscali.co.uk> - 2018-10-09 23:59 +0100
  Re: Testing for the presence of a file "John Williams (News)" <UCEbin@tiscali.co.uk> - 2018-10-08 14:50 +0100
    Re: Testing for the presence of a file "John Williams (News)" <UCEbin@tiscali.co.uk> - 2018-10-08 14:53 +0100
    Re: Testing for the presence of a file jgh@mdfs.net - 2018-10-21 19:57 -0700
      Re: Testing for the presence of a file jgh@mdfs.net - 2018-10-21 20:00 -0700
  Re: Testing for the presence of a file jgh@mdfs.net - 2018-10-21 19:55 -0700
    Re: Testing for the presence of a file Matthew Phillips <spam2011m@yahoo.co.uk> - 2018-10-23 07:43 +0100

csiph-web