Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.acorn.programmer > #5460
| From | Harriet Bazley <harriet@bazleyfamily.co.uk> |
|---|---|
| Newsgroups | comp.sys.acorn.programmer |
| Subject | Re: Filetype list |
| Message-ID | <cd42abf456.harriet@blueyonder.co.uk> (permalink) |
| References | <6a1b8ef056.harriet@blueyonder.co.uk> <e2af42f156.Matthew@sinenomine.freeserve.co.uk> |
| Organization | virginmedia.com |
| Date | 2018-05-07 23:21 +0100 |
On 1 May 2018 as I do recall,
Matthew Phillips wrote:
> In message <6a1b8ef056.harriet@blueyonder.co.uk>
> on 29 Apr 2018 Harriet Bazley wrote:
>
> > I've been trying to find out why Textseek's code to generate a list of all
> > available filetypes is crashing on the ARMiniX.
[snip]
> I did a simple test:
>
> *set ggg ""
> *show ggg
> ggg :
>
> Then in BASIC:
>
> DIM a% 256
> SYS"OS_ReadVarVal","ggg",a%,256,0,0 TO ,,len%
> P.len%
>
> This printed zero. So it's certainly possible to have zero bytes returned
> for the length in R2.
Yes, this definitely seems to be what was causing the problem - an
application setting up filetypes without giving them names.
>
> If you are trying to create a menu of all filetypes, then you could
> consider using the variable *name* instead of its value when R2 is
> returned as zero. Or extracting the hexadecomal part of the name and
> adding that to the menu.
I've gone for that version. Also, after a lot of fiddling around with
multiple nested conditions, WHILE versus REPEAT etc, it dawned on me that
having calculated the number of entries on the menu (in order to reserve
memory accordingly!) I could simply use the pre-calculated value in a
FOR...NEXT loop, and use the non-X form of the SWI instead of trying to trap
errors in order to end the loop:
FOR n% = 1 TO max%
SYS"OS_ReadVarVal","File$Type_*",block%,255,ptr% TO ,,bytes%,ptr%
IF bytes% THEN
block%?bytes%=13
$textptr%=FNs(block%)
ELSE
$(textptr%)=FNs(ptr%+10):REM use hex filetype for nameless variables
ENDIF
$(textptr%+10)=FNs(ptr%+10)
textptr%+=14
NEXT n%
It seems to work correctly in that the last entry on the menu is 'Zip',
which comes at the end of the alphabet - so nothing is being dropped off -
and the code is no longer causing buffer overruns by trying to access
non-existent strings in memory....
--
Harriet Bazley == Loyaulte me lie ==
Old Programmers never die. They just terminate and stay resident
Back to comp.sys.acorn.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Filetype list Harriet Bazley <harriet@bazleyfamily.co.uk> - 2018-04-29 23:38 +0100
Re: Filetype list Martin <News03@avisoft.f9.co.uk> - 2018-04-30 10:54 +0100
Re: Filetype list Harriet Bazley <harriet@bazleyfamily.co.uk> - 2018-04-30 23:43 +0100
Re: Filetype list tk@cestriant.plus.com - 2018-04-30 15:12 +0100
Re: Filetype list Matthew Phillips <spam2011m@yahoo.co.uk> - 2018-05-01 08:31 +0100
Re: Filetype list Martin <News03@avisoft.f9.co.uk> - 2018-05-01 10:47 +0100
Re: Filetype list Harriet Bazley <harriet@bazleyfamily.co.uk> - 2018-05-07 23:21 +0100
Re: Filetype list Harriet Bazley <harriet@bazleyfamily.co.uk> - 2018-05-07 23:37 +0100
csiph-web