Reading from file and EOF mark...

Started by MIRKOSOFT, July 15, 2010, 08:53 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!


I want to try to read any file byte per byte in assembler. For example, here's BASIC program which reads 10 bytes:

OPEN 1,11,1,”TESTFILE,S,R”
FOR X=1TO10:INPUT#1,A$:PRINT A$:NEXT
CLOSE 1



But I want to read it to end of File (EOF). What a mark has EOF?
'Cause when I'm reading directory in assembler it ends with $00...


But if in data are bytes with $00 value, how to find EOF?


Many thanks for every reply.


MIro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

bacon

Bacon
-------------------------------------------------------
Das rubbernecken Sichtseeren keepen das cotton-pickenen Hands in die Pockets muss; relaxen und watschen die Blinkenlichten.

LokalHorst

there is no specific EOF mark as part of the file data - you should check location $90 aka ST the IEC status byte.
bit7 - dev. not present
bit6 - EOF
bit1 - error during read (usually file not found)
bit0 - error during write (disk full etc.)

your routine should look like:

open file
readbyteloop: read byte

(do whatever)

bit $90
bvc readbyteloop
close file