beautypg.com

4 write(), Rite – Teledyne LeCroy Verification Script Engine (VSE) Manual User Manual

Page 94

background image

Teledyne LeCroy

Verification Script Engine Reference Manual




Page 94 of 115



19.4 Write()


This function writes data to the file.


Format:

Write(file_handle, value, num_of_bytes)


Parameters:

file_handle

"handle" to the file previously opened by OpenFile()


value

Data to write


num_of_bytes

Optional parameter specifying how many bytes to take from the
value parameter (if omitted, length is calculated automatically
based on the value type)

Remarks:

This function is primarily for binary files. It can be used for text files only if the value parameter is a string of text.
In that case, it is equivalent to the WriteString() function and the num_of_bytes parameter is ignored.

Example:


set BinFile = 0;

BinFile = OpenFile("C:\\data.bin", 0, _FO_BINARY);

# Write a string to the binary file.
Write(BinFile, "All we need is love!!!");

# Write a substring ("All") to the binary file.
Write(BinFile, "All we need is love!!!", 3);

val = 0xBEEF;
Write(BinFile, val); # Writes integer = (EF BE 00 00) to the binary file.
Write(BinFile, val, 2); # Writes WORD = (EF BE) to the binary file.

# Write a byte chain to the binary file.
Write(BinFile, 'AABBCCDDEEFF12345678');

# Write a list of values to the binary file.
Write(BinFile, [ 0xAA, "USB", 12, 0xBEEF ]);

CloseFile(BinFile); # Closes the binary file.