Teledyne LeCroy SAS_SATA Protocol Suite Verification Script Engine Reference Manual User Manual

Page 70

Advertising
background image


70

Example

# This example demonstrates CASE 1, how to open and read data.
# Opens file in binary mode with _APPEND functionality,
# to read data.
bin_file_handle = OpenFile("Sample.bin", _FC_RW_APPEND,
_FO_BINARY );


# Start reading from beginning of file.
SeekToBegin( bin_file_handle );
# "Some Text1"
string_val = ReadBin( bin_file_handle);
# 0x1234ABCD
integer_val= ReadBin( bin_file_handle);
# ‘00112233445566778899AABBCCDD'
raw_data = ReadBin( bin_file_handle,);
# ["one", 2, "three", [4, [5, [6]]]]
list_val = ReadBin( bin_file_handle);

CloseFile( bin_file_handle ); # Closes file.

……………………………………………………………………………………………………………………………………………………………………

# This example demonstrates CASE 2, how to read data from an
# already opened and written file.
# 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);

# Read the just-written content of this binary file.
# Start reading from beginning of file.
SeekToBegin( bin_file_handle );

# "Some Text1"
string_val = ReadBin( bin_file_handle);
# 0x1234ABCD
integer_val= ReadBin( bin_file_handle);
# ‘00112233445566778899AABBCCDD'
raw_data1 = ReadBin( bin_file_handle,);
# ["one", 2, "three", [4, [5, [6]]]]
list_val1 = ReadBin( bin_file_handle);

CloseFile( bin_file_handle ); # Closes file.

Advertising