• Basic - establishing a directory

    From Graham Pickles@21:1/5 to All on Wed Sep 23 14:56:02 2020
    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)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alan Adams@21:1/5 to Graham Pickles on Wed Sep 23 16:34:04 2020
    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/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Graham Pickles@21:1/5 to Alan Adams on Wed Sep 23 16:56:40 2020
    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)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Ashbery@21:1/5 to graham@durain.uk on Wed Sep 23 17:42:19 2020
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Ashbery@21:1/5 to alan@adamshome.org.uk on Wed Sep 23 18:00:05 2020
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Graham Pickles@21:1/5 to Richard Ashbery on Thu Sep 24 09:29:35 2020
    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)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Alan Adams@21:1/5 to Graham Pickles on Thu Sep 24 10:19:39 2020
    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/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Theo@21:1/5 to Alan Adams on Thu Sep 24 11:30:24 2020
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From svrsig@21:1/5 to Theo on Tue Oct 20 09:54:12 2020
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)