Chapter 18: file functions, 1 openfile(), Chapter 18 – Teledyne LeCroy SAS_SATA Protocol Suite Verification Script Engine Reference Manual User Manual

Page 66: File functions

Advertising
background image


66

Chapter 18:

File Functions

This group of functions covers VSE capabilities to work with the external files.

18.1 OpenFile()

This function opens a read-write file for writing or appending content.


Format :

OpenFile( file_path, file_creation_type = 0, file_open_type = 0 )


Parameters

file_path

Full path of the file to open (for ‘\’ use ‘\\’)

If the path is not specified, the file is in the USER folder.

file_creation_type

_FC_RW_CREATE
Writes new content to the file by replacing the previous content.
Note: _FC_RW_CREATE ERASEs the file content (if any)
while it is opening.


_FC_RW_APPEND
Appends/adds new content at the end of the previous file
content without replacing the same.

file_open_type

_FO_TEXT opens as a Text document (*.txt).
_FO_BINARY opens as a Binary file.


Return Values

The "handle" to the file to be used in other file functions.


Example

set file_handle = 0;


# Opens file with default options (“<path>”, 0, 0), to open as
# a text document and to overwrite its previous contents.

file_handle = OpenFile( "D:\\Log.txt" );


# Write text string to file.
WriteString(file_handle, "Some Text1" );
# Write text string to file.
WriteString( file_handle, "Some Text2" );

CloseFile( file_handle ); # Closes file.


# Opens file in Binary mode with _APPEND functionality.
file_handle = OpenFile("Sample.bin", _FC_RW_APPEND, _FO_BINARY
);

# Write text string to file.
WriteBin( file_handle, "Some Text1" );
# Write integer to file.
WriteBin( file_handle, 0x1234ABCD);

CloseFile( file_handle ); # Closes file.

Advertising