4 writebin (), Rite – Teledyne LeCroy SAS_SATA Protocol Suite Verification Script Engine Reference Manual User Manual
Page 68
68
18.4 WriteBin ()
This function writes content to a binary file.
Format :
WriteBin( bin_file_handle, variable )
Parameters
bin_file_handle
File handle for the binary file (only opened using
_FO_BINARY), to which the contents are to be written.
variable
Any variable type (integer, string, list, and raw string)
Return Value
_BF_RW_OK
Read/Write binary returns succesfully
_BF_RW_INVALID_HANDLE (1)
Invalid File Handle
_BR_RW_INALID_VALUE
Invalid Value
Example
…
# Opens file in binary mode with _CREATE functionality.
bin_file_handle = OpenFile("Sample.bin", _FC_RW_CREATE,
_FO_BINARY );
…
raw_data = ‘00112233445566778899AABBCCDD';
list_val = ["one", 2, "three", [4, [5, [6]]]];
# Write text string to file.
WriteBin( bin_file_handle, "Some Text1" );
# Write integer to file.
WriteBin( bin_file_handle, 0x1234ABCD);
# Write raw data to file.
WriteBin( bin_file_handle, raw_data);
# Write list to file.
WriteBin( bin_file_handle, list_val);
…
CloseFile( bin_file_handle ); # Closes file.