Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #5686
| From | Martin <News03@avisoft.f9.co.uk> |
|---|---|
| Subject | Re: Traversing a directory in BASIC... |
| Newsgroups | comp.sys.acorn.programmer |
| Date | 2019-01-22 16:30 +0000 |
| Message-ID | <577a7070fcNews03@avisoft.f9.co.uk> (permalink) |
| References | <5551f8d2-bbd0-4d15-aa64-bc799be24414@googlegroups.com> <577a109ff4News03@avisoft.f9.co.uk> <d81f5a7a57.Alan.Adams@ArmX6.adamshome.org.uk> |
| Organization | None |
On 22 Jan in article <d81f5a7a57.Alan.Adams@ArmX6.adamshome.org.uk>, Alan Adams <alan@adamshome.org.uk> wrote: > In message <577a109ff4News03@avisoft.f9.co.uk> > Martin <News03@avisoft.f9.co.uk> wrote: > > On 21 Jan in article > > <5551f8d2-bbd0-4d15-aa64-bc799be24414@googlegroups.com>, > > <usenet@garethlock.com> wrote: > >> I'm trying to write a routine that returns a list of items, both > >> files and directories, in a given directory. Think I might have > >> hit on something using OS_GBPB, but one has to supply the number > >> of items to read. Been trying OS_FSControl 28 to return a count > >> before calling OS_GBPB, can get this to count files, but not > >> directories... > >> Has anyone come across a better way of doing this?? > > Nope. OS_GBPB is the way to go. The number of objects to read on > > entry is the *maximum* to read in one go. > So the simplest way for you to use this is to set the number to > read to 1, then you either get a file/directory, or nothing. That will work. However, if you have a directory with lots of entries, it is better to create a buffer that can take many entries so that the SWI is called fewer times. Note that the Action you use (9, 10, 11 or 12) dictates the amount of information returned, from just filename to 29 bytes+filename, so a 2048 byte buffer can hold from roughly 180 to 60 entries (assuming file names averaging 10 characters). Note that if you specify a larger number to read than will fit in the buffer then OS_GBPB is savvy enough to stop before the buffer is overrun, so the number to read can be set high. > > The actual number that has been read is returned, and it may be > > zero. To go to the end of a directory you need to repeat until > > r4=-1. > > A simple structure for the code can be seen in the OS StrongHelp > > manual, if you do not have the PRMs. That structure will just work. Anything else is very liable to cause problems in some way or another. -- Martin Avison Note that unfortunately this email address will become invalid without notice if (when) any spam is received.
Back to comp.sys.acorn.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Traversing a directory in BASIC... usenet@garethlock.com - 2019-01-21 13:48 -0800
Re: Traversing a directory in BASIC... Gerald Holdsworth <nospam@hollypops.co.uk> - 2019-01-21 22:18 +0000
Re: Traversing a directory in BASIC... Steve Fryatt <news@stevefryatt.org.uk> - 2019-01-21 22:44 +0000
Re: Traversing a directory in BASIC... usenet@garethlock.com - 2019-01-21 15:02 -0800
Re: Traversing a directory in BASIC... Steve Fryatt <news@stevefryatt.org.uk> - 2019-01-21 23:59 +0000
Re: Traversing a directory in BASIC... usenet@garethlock.com - 2019-01-21 18:12 -0800
Re: Traversing a directory in BASIC... Matthew Phillips <spam2011m@yahoo.co.uk> - 2019-01-22 08:14 +0000
Re: Traversing a directory in BASIC... Martin <News03@avisoft.f9.co.uk> - 2019-01-21 23:04 +0000
Re: Traversing a directory in BASIC... usenet@garethlock.com - 2019-01-21 15:53 -0800
Re: Traversing a directory in BASIC... Alan Adams <alan@adamshome.org.uk> - 2019-01-22 12:26 +0000
Re: Traversing a directory in BASIC... Martin <News03@avisoft.f9.co.uk> - 2019-01-22 16:30 +0000
Re: Traversing a directory in BASIC... jgh@mdfs.net - 2019-01-23 05:26 -0800
Re: Traversing a directory in BASIC... Alan Adams <alan@adamshome.org.uk> - 2019-01-23 15:01 +0000
Re: Traversing a directory in BASIC... David Higton <dave@davehigton.me.uk> - 2019-01-24 14:35 +0000
Re: Traversing a directory in BASIC... Richard Porter <dontusethis@address.uk.invalid> - 2019-01-27 23:33 +0000
csiph-web