GETC returns the ASCII code value of a character from the input of the file in the hFile parameter and increments the file pointer to point to the next character in the file.
Syntax:RetVal = GETC(hFile AS FILE) Return Value:
Parameters:
|
Cut and save the example as GETC.BAS. Translate and compile it. Run it as GETC | more.
DIM a$ DIM b% OPEN "getc.bin" FOR BINARY NEW AS FP1 FOR INTEGER O = 0 TO 255 a$ = CHR$(O) PUT$ FP1, a$, 1 NEXT O CLOSE FP1 OPEN "getc.bin" FOR BINARY AS FP1 FOR INTEGER O = 0 TO 255 b% = GETC(FP1) PRINT b% NEXT O CLOSE FP1 END
PUTC places in the specified file, at the location of the current file pointer, the ASCII integer code value of a character.
Syntax:PUTC(hFile AS FILE, ASCIICode AS INTEGER) Parameters:
|
OPEN "test.txt" FOR OUTPUT AS #1 FOR CHAR i = 65 TO 70 PUTC #1, i NEXT PUTC #1, 13 ' 13 = Carriage Return PUTC #1, 10 ' 10 = Line Feed FLUSH #1 ' optional but always a good idea to FLUSH when you're done :-) CLOSE #1