Thanks for the suggestion Robert. Below is the entry into Revisions.txt for the next version of BCX:
Robert Wishlaw : Added PUTC (byte_expression, FilePtr) to the BCX lexicon as a complement to GETC(FP#)
PUTC will accept QBASIC style file pointers. Here is a compilable example:
OPEN "test.txt" FOR OUTPUT AS #1
FOR CHAR i = 65 TO 70 ' The letters ABCDEF
PUTC (#1, i)
NEXT
PUTC (#1, 10 + 1 + 1 + 1) ' 13 = Carriage Return ( I used this line to test the parser )
PUTC (#1, 10) ' 10 = Line Feed
FLUSH(#1) ' optional but always a good idea to FLUSH when you're done :-)
CLOSE #1
The StdC call is putc (byte, FP);
but I wanted to rearrange the arguments, so that a byte expression could be more easily parsed, when needed.
Hence this crazy looking test line: PUTC (#1, 10 + 1 + 1 + 1) ' 13 = Carriage Return
The internal BCX processor for the new PUTC command is:
CASE "putc" ' MrBcx 819 (New)
Stk$[Tmp] = "putc" ' MrBcx 819 (New)
REMOVE "#" FROM Stk$[Tmp+2] ' MrBcx 819 (New)
IF DataType(Stk$[Tmp+2]) = vt_NUMBER THEN ' MrBcx 819 (New)
Stk$[Tmp+2] = "FP" + Stk$[Tmp+2] ' MrBcx 819 (New)
END IF ' MrBcx 819 (New)
' ' MrBcx 819 (New) Rearrange: putc ( fp# , byte-expreession )
' ' MrBcx 819 (New) to: putc ( byte-expression, fp# )
DIM fp$ ' MrBcx 819 (New)
fp$ = Stk$[Tmp+2] ' MrBcx 819 (New)
LShiftStk(Tmp+2) ' MrBcx 819 (New)
LShiftStk(Tmp+2) ' MrBcx 819 (New)
Stk$[Ndx] = "," ' MrBcx 819 (New)
INCR Ndx ' MrBcx 819 (New)
Stk$[Ndx] = fp$ ' MrBcx 819 (New)
INCR Ndx ' MrBcx 819 (New)
Stk$[Ndx] = ")" ' MrBcx 819 (New)
It is working as it should and will be included in 8.1.9
Thanks ...