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


Groups > comp.sys.acorn.programmer > #6184 > unrolled thread

Basic - establishing a directory

Started byGraham Pickles <graham@durain.uk>
First post2020-09-23 14:56 +0100
Last post2020-09-23 17:42 +0100
Articles 9 — 5 participants

Back to article view | Back to comp.sys.acorn.programmer


Contents

  Basic - establishing a directory Graham Pickles <graham@durain.uk> - 2020-09-23 14:56 +0100
    Re: Basic - establishing a directory Alan Adams <alan@adamshome.org.uk> - 2020-09-23 16:34 +0100
      Re: Basic - establishing a directory Graham Pickles <graham@durain.uk> - 2020-09-23 16:56 +0100
      Re: Basic - establishing a directory Richard Ashbery <basura@invalid.addr.uk> - 2020-09-23 18:00 +0100
        Re: Basic - establishing a directory Graham Pickles <graham@durain.uk> - 2020-09-24 09:29 +0100
          Re: Basic - establishing a directory Alan Adams <alan@adamshome.org.uk> - 2020-09-24 10:19 +0100
            Re: Basic - establishing a directory Theo <theom+news@chiark.greenend.org.uk> - 2020-09-24 11:30 +0100
              Re: Basic - establishing a directory svrsig <chris@svrsig.org> - 2020-10-20 09:54 -0700
    Re: Basic - establishing a directory Richard Ashbery <basura@invalid.addr.uk> - 2020-09-23 17:42 +0100

#6184 — Basic - establishing a directory

FromGraham Pickles <graham@durain.uk>
Date2020-09-23 14:56 +0100
SubjectBasic - establishing a directory
Message-ID<9a3486b458.graham@graham.durain.uk>
Computer System is on a Laptop Lenovo using RISCBOOKQUAD
using Windows Pro 7. RISCOS 4.02. Programming in Basic.

I want to WITHIN a Basic program
(i) check whether a particular directory is present at for instance
    HostFS::HardDisc4.$.Deposits.Trial
(ii) if not to establish an empty directory entitled Trial at that
location

Getting old aren't we all! Probably quite simple but for some reason
it's eluding me. Can anyone produce suitable Basic or point me in the
right direction.

Sorry if this is really trivial.

-- 
Graham Pickles
One should always play fairly when one has the winning cards. (Oscar
Wilde)

[toc] | [next] | [standalone]


#6185

FromAlan Adams <alan@adamshome.org.uk>
Date2020-09-23 16:34 +0100
Message-ID<532e8fb458.Alan.Adams@ArmX6.adamshome.org.uk>
In reply to#6184
In message <9a3486b458.graham@graham.durain.uk>
          Graham Pickles <graham@durain.uk> wrote:

> Computer System is on a Laptop Lenovo using RISCBOOKQUAD
> using Windows Pro 7. RISCOS 4.02. Programming in Basic.

> I want to WITHIN a Basic program
> (i) check whether a particular directory is present at for instance
> 
> (ii) if not to establish an empty directory entitled Trial at that
> location HostFS::HardDisc4.$.Deposits.Trial

> Getting old aren't we all! Probably quite simple but for some reason
> it's eluding me. Can anyone produce suitable Basic or point me in the
> right direction.

> Sorry if this is really trivial.

*cdir HostFS::HardDisc4.$.Deposits.Trial
will create it if it doesn't exist, and doesn't error if it did exist.

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

[toc] | [prev] | [next] | [standalone]


#6186

FromGraham Pickles <graham@durain.uk>
Date2020-09-23 16:56 +0100
Message-ID<e13f91b458.graham@graham.durain.uk>
In reply to#6185
In message <532e8fb458.Alan.Adams@ArmX6.adamshome.org.uk>
          Alan Adams <alan@adamshome.org.uk> wrote:

>In message <9a3486b458.graham@graham.durain.uk>
>          Graham Pickles <graham@durain.uk> wrote:
>
>> Computer System is on a Laptop Lenovo using RISCBOOKQUAD
>> using Windows Pro 7. RISCOS 4.02. Programming in Basic.
>
>> I want to WITHIN a Basic program
>> (i) check whether a particular directory is present at for instance
>>
>> (ii) if not to establish an empty directory entitled Trial at that
>> location HostFS::HardDisc4.$.Deposits.Trial
>
>> Getting old aren't we all! Probably quite simple but for some reason
>> it's eluding me. Can anyone produce suitable Basic or point me in the
>> right direction.
>
>> Sorry if this is really trivial.
>
>*cdir HostFS::HardDisc4.$.Deposits.Trial
>will create it if it doesn't exist, and doesn't error if it did exist.
>
Of course. Works perfectly. As I said I'm getting old and even simple
pogrammingasks are taking longer ! Many thanks for taking the
time to reply.

Regards,

-- 
Graham Pickles
It's never too late to start planning for the future. (Unknown)

[toc] | [prev] | [next] | [standalone]


#6188

FromRichard Ashbery <basura@invalid.addr.uk>
Date2020-09-23 18:00 +0100
Message-ID<58b4970e7fbasura@invalid.addr.uk>
In reply to#6185
In article <532e8fb458.Alan.Adams@ArmX6.adamshome.org.uk>, Alan
Adams
<alan@adamshome.org.uk> wrote:
> In message <9a3486b458.graham@graham.durain.uk> Graham Pickles
>           <graham@durain.uk> wrote:

> > Computer System is on a Laptop Lenovo using RISCBOOKQUAD using
> > Windows Pro 7. RISCOS 4.02. Programming in Basic.

> > I want to WITHIN a Basic program (i) check whether a particular
> > directory is present at for instance
> > 
> > (ii) if not to establish an empty directory entitled Trial at
> > that location HostFS::HardDisc4.$.Deposits.Trial

> > Getting old aren't we all! Probably quite simple but for some
> > reason it's eluding me. Can anyone produce suitable Basic or
> > point me in the right direction.

> > Sorry if this is really trivial.

> *cdir HostFS::HardDisc4.$.Deposits.Trial will create it if it
> doesn't exist, and doesn't error if it did exist.

Its simpler but I do like a bit more information and is where...
SYS "OS_File", 17, "SDFS::HardDisc0.$.mydir" TO type%
comes into its own. SWI returns 0 if object can't be found. If object
exists and returns 2 then its a directory and 1 if its a file.

Richard

[toc] | [prev] | [next] | [standalone]


#6189

FromGraham Pickles <graham@durain.uk>
Date2020-09-24 09:29 +0100
Message-ID<7627ecb458.graham@graham.durain.uk>
In reply to#6188
In message <58b4970e7fbasura@invalid.addr.uk>
          Richard Ashbery <basura@invalid.addr.uk> wrote:

>In article <532e8fb458.Alan.Adams@ArmX6.adamshome.org.uk>, Alan
>Adams
><alan@adamshome.org.uk> wrote:
>> In message <9a3486b458.graham@graham.durain.uk> Graham Pickles
>>           <graham@durain.uk> wrote:
>
>> > Computer System is on a Laptop Lenovo using RISCBOOKQUAD using
>> > Windows Pro 7. RISCOS 4.02. Programming in Basic.
>
>> > I want to WITHIN a Basic program (i) check whether a particular
>> > directory is present at for instance
>> >
>> > (ii) if not to establish an empty directory entitled Trial at
>> > that location HostFS::HardDisc4.$.Deposits.Trial
>
>> > Getting old aren't we all! Probably quite simple but for some
>> > reason it's eluding me. Can anyone produce suitable Basic or
>> > point me in the right direction.
>
>> > Sorry if this is really trivial.
>
>> *cdir HostFS::HardDisc4.$.Deposits.Trial will create it if it
>> doesn't exist, and doesn't error if it did exist.
>
>Its simpler but I do like a bit more information and is where...
>SYS "OS_File", 17, "SDFS::HardDisc0.$.mydir" TO type%
>comes into its own. SWI returns 0 if object can't be found. If object
>exists and returns 2 then its a directory and 1 if its a file.
>
>Richard
>
Yes, I think it is probably a bit wiser not to ignore the fact that the
directory may already exist. My excuse is that I'm trying out an idea
and don't expect anyone else to use my program at present. If my idea is
successful then I will revamp to make it as a proper fully thought out
program unlikely to mislead others or myself in the future!

Thanks for the info. Have not used SYS "OS_File",17 before.

Regards,

-- 
Graham Pickles
An idiot with a computer is a faster better idiot. (Rich Julius)

[toc] | [prev] | [next] | [standalone]


#6190

FromAlan Adams <alan@adamshome.org.uk>
Date2020-09-24 10:19 +0100
Message-ID<eabcf0b458.Alan.Adams@ArmX6.adamshome.org.uk>
In reply to#6189
In message <7627ecb458.graham@graham.durain.uk>
          Graham Pickles <graham@durain.uk> wrote:

> In message <58b4970e7fbasura@invalid.addr.uk>
>           Richard Ashbery <basura@invalid.addr.uk> wrote:

<snip>

>>
> Yes, I think it is probably a bit wiser not to ignore the fact that the
> directory may already exist. My excuse is that I'm trying out an idea
> and don't expect anyone else to use my program at present. If my idea is
> successful then I will revamp to make it as a proper fully thought out
> program unlikely to mislead others or myself in the future!

Indeed, in some cases it might be necessary to distinguish between three 
possibilities:

No directory exists
Empty directory exists
Directory exists and has contents. For this one I *think* it's possible to 
search for a file called * in the directory.

> Thanks for the info. Have not used SYS "OS_File",17 before.

> Regards,



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

[toc] | [prev] | [next] | [standalone]


#6191

FromTheo <theom+news@chiark.greenend.org.uk>
Date2020-09-24 11:30 +0100
Message-ID<8Nh*q1X2x@news.chiark.greenend.org.uk>
In reply to#6190
Alan Adams <alan@adamshome.org.uk> wrote:
> Indeed, in some cases it might be necessary to distinguish between three 
> possibilities:
> 
> No directory exists
> Empty directory exists
> Directory exists and has contents. For this one I *think* it's possible to 
> search for a file called * in the directory.

Plus 'exists and it's a file' and 'exists and it's an image file'.

(it's a common corner case to do unexpected things when it's of the wrong
type, and image files additionally muddy the waters)

Theo

[toc] | [prev] | [next] | [standalone]


#6192

Fromsvrsig <chris@svrsig.org>
Date2020-10-20 09:54 -0700
Message-ID<e9affd33-de65-4507-87db-da10594da2c2o@googlegroups.com>
In reply to#6191
On Thursday, September 24, 2020 at 11:30:27 AM UTC+1, Theo wrote:
> Alan Adams <alan@adamshome.org.uk> wrote:
> > Indeed, in some cases it might be necessary to distinguish between three 
> > possibilities:
> > 
> > No directory exists
> > Empty directory exists
> > Directory exists and has contents. For this one I *think* it's possible to 
> > search for a file called * in the directory.
> 
> Plus 'exists and it's a file' and 'exists and it's an image file'.
> 
> (it's a common corner case to do unexpected things when it's of the wrong
> type, and image files additionally muddy the waters)
> 
> Theo

An image file is seen as a file if the owning application is dormant.

[toc] | [prev] | [next] | [standalone]


#6187

FromRichard Ashbery <basura@invalid.addr.uk>
Date2020-09-23 17:42 +0100
Message-ID<58b4956df9basura@invalid.addr.uk>
In reply to#6184
In article <9a3486b458.graham@graham.durain.uk>, Graham Pickles
<graham@durain.uk> wrote:
> Computer System is on a Laptop Lenovo using RISCBOOKQUAD using
> Windows Pro 7. RISCOS 4.02. Programming in Basic.

> I want to WITHIN a Basic program (i) check whether a particular
> directory is present at for instance
>     HostFS::HardDisc4.$.Deposits.Trial (ii) if not to establish an
> empty directory entitled Trial at that location

> Getting old aren't we all! Probably quite simple but for some
> reason it's eluding me. Can anyone produce suitable Basic or point
> me in the right direction.

Is this any use:

Assuming directory name is 'mydir'

SYS "OS_File", 17, "SDFS::HardDisc0.$.mydir" TO type%
IF type% = 2 THEN PRINT "Directory, mydir already exists" ELSE
PRINT "Unable to locate directory, mydir but I'll create one for you."
SYS "OS_File",8,"SDFS::HardDisc0.$.Mydir"

The path (eg. "SDFS::HardDisc0.$.mydir") is set up for my Raspberry Pi
and will have to be altered for your machine.

Richard

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.acorn.programmer


csiph-web