IO_FLINE/IOB_FLIN & IO_FSTRG/IOB_FMUL
These traps read a set of bytes from a channel.
Call Parameters | Return Parameters | ||
---|---|---|---|
D0.B | $02 or $03 | D0.L | Error code. |
D1.L | D1.W | Number of bytes fetched. | |
D2.W | Length of buffer. | D2.L | Preserved. |
D3.W | Timeout. | D3.L | Preserved. |
A0.L | Channel ID | A0.L | Preserved. |
A1.L | Pointer to buffer. | A1.L | Pointer to one byte after the last fetched. |
Errors
ERR_NC | Not complete. |
ERR_NO | Channel not open. |
ERR_EF | End of file. |
ERR_BO | Buffer overflow. |
Notes
- All registers not shown above are not used on entry and are preserved on exit.
- D0.B is $02 for IO_FLINE/IOB_FLIN and $03 for IO_FSTRG/IOB_FMUL.
- IO_FLINE/IOB_FLIN fetches a line of bytes ending with LF ($0A). The LF is included as the last character fetched. If the number of bytes read before LF is reached exceeds the size of the buffer a buffer overflow error occurs.
- IO_FSTRG/IOB_FMUL reads the number of bytes specified in D2.W unless EOF is reached first.
- If bytes are being read from a CON channel the actions of the two Traps are different. For IO_FLINE/IOB_FLIN the cursor is enabled and the characters are mirrored in the window. Also the arrow keys can be used to edit the line in the normal way. For IO_FSTRG/IOB_FMUL the characters are not printed in the window and any cursor handling is up to the application.
Example
input moveq #io_fstrg,d0 moveq 1024,d2 ; Buffer max size moveq #-1,d3 ; Infinite timeout lea input_buffer,a1 ; Read data into here move.l a1,-(a7) ; Save buffer address trap #2 cmpi.w #ERR_EF,d0 ; EOF? beq.s input_end ; Yes tst.w d0 ; Any other error? bne.s input_end ; Yes input_end move.l (a7)+,a1 ; Restore buffer rts ; D0 = error code, ERR_EF or zero input_buffer ds.w 1 ds.b 1024