.fread/.freadw

.fread handle, label

This reads a byte (.fread) or word (.freadw) from the file handle and stores the result in the label label. The position of the pointer in the file stream is shunted along to point to the next byte/word.

; Open the file 'hello.txt' and include the data, stripping out the letter 'e':

.fopen fhnd, "hello.txt"        ; fhnd is our handle
.fsize fhnd, hello_size         ; hello_size = size of "hello.txt" in bytes

.for i, 1, hello_size           ; Go through each byte...
    .fread fhnd, chr            ; Read a byte and store it as "chr"
    .if chr!='e' && chr!='E'    ; is it an "e"?
        .db chr                 ; No, so output it.
    .endif
.loop

.fclose fhnd                    ; Close our file handle.