TMWriteFile Overview Group

The TMWriteFile API call writes the file specified by the file handle 'file_handle' with the data from the buffer 'write_buffer', containing 'num_write' bytes. 'file_handle' must be set as a result of a call to TMCreateFile. This API call works only with regular files with extensions 0-99 decimal and the ‘Monetary File’ with extension 101. For ‘add’ files with extension 100 decimal, use the API call TMWriteAddFile. In case of the ‘Monetary File’, multiple retries will NOT be attempted. If the file was written many times, then the counter would not end up where it was expected. If this function fails then the file must be closed and then recreated with TMCreateFile. If the Counter has changed then the file needs to be re-encrypted.

short far pascal TMWriteFile(

long session_handle,              // session handle for the desired 1-Wire network
void far *state_buffer,           // state buffer provided for the 1-Wire network session
short file_handle,                // file handle
unsigned char far *write_buffer,  // buffer containing the file data to write
short num_write                   // number of bytes to write

For a description of the above types, see the TMEX Type Descriptions.



Specifies the session handle returned from the API function TMExtendedStartSession that specifies the desired 1-Wire network port. This parameter is required by most TMEX API functions.


Specifies a pointer to a memory location that TMEX keeps all of the state information for the 1-Wire networks. This parameter is required by most TMEX API functions.


Specifies a file handle of the file to read.


Specifies a pointer to a buffer that contains the data to write to the file. It must be at least ‘num_write’ bytes long.


Specifies the number of bytes to write from the ‘write_buffer’.

Return Value

>= 0 => file written, and this is the number of bytes
<0 => TMEX File Operations Error Return Code

Code Example

See Also