lr.readFile

Reads a file into a parameter.

Java Language

lr.readFile( filename, output parameter name, continue on error );

ExampleString and Parameter Functions

Arguments

NameComments
filenameThe full pathname or the pathname relative to the script folder.
output parameter nameThe name of the parameter that stores the file contents.
continue on errorlr.EXIT_VUSER (0) or
lr.EXIT_ACTION_AND_CONTINUE (1)

lr.readFile reads a file and saves the file contents in a parameter.

Return Values

This function returns the number of bytes read. On failure, returns a negative number.

Parameterization

Parameterization is not applicable to this function.

Example

This action shows the usages of lr.readFile.

function Action()
{
    // EXIT_ACTION_AND_CONTINUE on error
	lr.readFile("test.txt","testparam", lr.EXIT_ACTION_AND_CONTINUE);
	lr.logMessage(lr.evalString("{testparam}"));
			
	// EXIT_VUSER on error
	lr.readFile("notfound2.txt","notfound2", lr.EXIT_VUSER);
			
    return 0;
}