Openfile(), 1 openfile() – Teledyne LeCroy UWBTracer Verification Script Engine Manual User Manual

Page 71

Advertising
background image

LeCroy Corporation

Verification Script Engine Manual, version 2.2





18.1 OpenFile()


This function opens a file for writing.


Format:

OpenFile(file_path, append, mode)


Parameters:

file_path

Full path to the file to open. (For ‘\’ use ‘\\’)

append

This parameter (if present and not equal to 0) specifies that VSE should append
the following write operations to the contents of the file; otherwise, the
contents of the file are cleared.

mode

This parameter specifies the open mode (text or binary) for the file.
If omitted, text mode is used. It can be one of the following values:
_FO_BINARY (= 0): Opens file in binary mode
_FO_TEXT (= 1): Opens file in text mode (by default)


Return Values:

The “handle” to the file to be used in other file functions.


Example:

set file_handle = 0;

file_handle = OpenFile(“D:\\Log.txt”); # Opens file in text mode.

# The previous contents

# are erased.

WriteString(file_handle, “Some Text1”); # Write text string to file.

WriteString(file_handle, “Some Text2”); # Write text string to file.

CloseFile(file_handle); # Closes the file.

# Opens file in text mode.

# The following file operations append to the contents of the file.

file_handle = OpenFile(GetApplicationFolder() + “Log.txt”, _APPEND);

# Opens file in binary mode. The previous contents are erased.

file_handle = OpenFile(“D:\\data.bin”, 0, _FO_BINARY);

Write(file_handle, 0xAABBCCDD); # Writes integer value into the binary file.

CloseFile(file_handle); # Closes the binary file.

Page 71 of 95



Advertising