[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help! (BASIC.SYSTEM)



On 19 Dec 2000 00:00:08 -0500, dalloff@gcfn.org (Dave Althoff Jr)
wrote:

>I'm about to write a routine to convert some normalized text files to HTML.

Cool.  I haven't see anyone else address your questions yet so I'll
answer them even if it is over a week since you asked

>Trouble is, I have to do it in ProDOS.  Other trouble is, I can't detect
>the end of the file in Applesoft.

Well, you can detect the size of certain files under ProDOS.  If you
are dealing with a text file you can look at the ENDFILE column in a
directory listing.  You can also pull this information out using a
program.

Here is an example program to do this.  A$ must be set to the filename
(case sensitive) of the text file you want to get the size of.

REM Get current prefix
100 PRINT CHR$(4);"PREFIX"
REM And put it in PF$
110 INPUT PF$
REM Open that directory as a text file
120 PRINT CHR$(4);"OPEN";PF$
REM Read that directory
130 PRINT CHR$(4);"READ";PF$
REM If we find the correct file we get out of loop
140 INPUT L$: IF MID$(L$,2,LEN(A$)) = A$ THEN 170
REM If not at the end of the directory listing keep looping
150 IF LEFT$(L$,6) <> "BLOCKS" THEN 140
REM Hit end of listing without finding the file so let user know
160 PRINT "Didn't find a file called ";A$: PRINT CHR$(4);"CLOSE": END
REM Close the directory
170 PRINT CHR$(4);"CLOSE"
REM Optional check to make sure we have the right filetype
180 IF MID$(L$,18,3) <> "TXT" THEN PRINT "Wrong file type": END
REM Set LF to length of file
REM (can't use an integer here as the size could be quite large)
190 LF = VAL(MID$(L$,64,8))

LF will now have the size in bytes of the text file.

If you were to use a small assembly routine you could use it to get
the size of any type of file.  If you'd like a routine to do that, let
me know and I'll type one up for you.

>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.

You can still use this method under ProDOS.  Error 5 is still END OF
DATA.

>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...If the codes are not the same, anybody got a list
>handy?

If you like the entire list of errors let me know and I'll type them
up for you.  I can't remember the DOS 3.3 ones anymore so I can't say
for sure whether any have changed or if any were added.  I'm also
getting ready to leave for work right now otherwise I would have just
typed them in now.  :-)