@FILEWRITEB[n,length,string] : Writes the specified number of bytes from the string to the file whose handle is n. Returns the number of bytes written, or -1 if an error occurred.

 

Note: Writes ASCII output when passed a Unicode string. Note that if you're trying to write non-English (>128) characters with @FILEWRITEB, the output will probably not match the input.

 

If the length argument is -1, @FILEWRITEB will read the string argument as a series of ASCII values in decimal or hex to write to the file. For example:

 

         echo %@filewriteb[%file,-1,0xe0 0xF2 0xA9]

 

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.

 

Example:

 

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

echo writing %@filewriteb[%h,10,Write some characters from this string]

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

 

See also the related handle-based functions:

 

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