[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help! (BASIC.SYSTEM)
- Subject: Re: Help! (BASIC.SYSTEM)
- From: dempson@actrix.gen.nz (David Empson)
- Date: Tue, 19 Dec 2000 23:55:39 +1300
- Newsgroups: comp.sys.apple2
- Organization: Empsoft
- References: <91mq0o$bkv$1@acme.gcfn.org>
- User-agent: MacSOUP/2.4.2
- Xref: supernews.google.com comp.sys.apple2:4553
Dave Althoff Jr <dalloff@gcfn.org> wrote:
> I'm about to write a routine to convert some normalized text files to HTML.
>
> Trouble is, I have to do it in ProDOS. Other trouble is, I can't detect
> the end of the file in Applesoft.
>
> Now, under DOS 3.3, I can use ONERR GOTO and then PEEK(222) and look for a
> 5 (END OF DATA) to make sure I'm getting the failure that I think I'm getting.
This will also work fine in ProDOS.
Another option is to open and read the catalog, locate the appropriate
file and parse the length, so you know exactly how many bytes to expect.
Yet another option is to get BASIC.SYSTEM to do a GET_EOF call for you,
and PEEK out the resulting length from the parameter block in the
BASIC.SYSTEM global page. This parameter block is shared between
several calls, so you need to time it right.
It could be done with a small machine code routine which calls the
kernel (or does it via BASIC.SYSTEM's system call function).
After OPENing the file, try the following:
POKE 48839,PEEK(48848): REM Copy the file reference number
POKE 768,169: POKE 769,209: REM LDA #$D1 = GET_EOF
POKE 770,32: POKE 771,112: POKE 772,190: JSR $BE70 = GOSYSTEM
POKE 773,133: POKE 774,0: REM STA $00
POKE 775,96: REM RTS
CALL 768
This will do a GET_EOF call on the file which was just OPENed, and store
the error code in memory location 0 (0 if no error, else a normal
BASIC.SYSTEM error code).
If there was no error, you can now PEEK the 24-bit end of file value
(file length) from locations 48840 (low byte) through 48842 (high byte).
> Are the errir (Errir? I think that's an Error #16* right there) codes the
> same in BASIC.SYSTEM as under DOS 3.3? I presume I still POKE 216,0 to
> clear the error flag...
All the same.
You should also use the stack cleanup code in either DOS 3.3 or PRODOS,
or you could eventually get a stack overflow: this can be done with a
CALL into Applesoft (-3288), and should be used unless you are going to
RESUME.