Please enable JavaScript to view this site.

CMDebug / TCC-RT Help v. 29

@FILEREADB[n,length[,h x]] : Reads length bytes of data from the file whose handle is n. Returns the string **EOF** if you attempt to read past the end of the file. The data will be returned as a string of space-separated numeric digits representing the ASCII value of each character.


The optional third parameter (h or x) species the output format:


hOutput is 2-digit hex (00 - FF)
xOutput is 0x00 - 0xFF)


Numeric input may be entered in either decimal format (a sequence of 0-9 digits) or in hexadecimal format ("0x" followed by a sequence of 0-F hex digits).


This function should only be used with file handles returned by @FILEOPEN. If you use it with any other number you may damage other files opened by TCC (or by the program which started TCC).


Beware of characters with special meaning to TCC, such as redirection and piping symbols, within the file. Use SETDOS /X with appropriate codes as needed.




set h=%@fileopen["d:\path\myfile.txt",r]

echo reading %@filereadb[%h,32]

echo closing handle #%h: %@fileclose[%h]


See also the related handle-based functions:


@FILECLOSEClose a file handle
@FILEOPENOpen a file handle
@FILESEEKMove a file handle pointer
@FILESEEKLMove a file handle pointer to a specified line
@FILEWRITEWrite next line to a file handle
@FILEWRITEBWrite data to a file handle
@TRUNCATETruncate the file at the current position of the file handle pointer.