Reads a file into a parameter.


int lr.read_file( string <filename>, string <output parameter name>, int <continue on error>);

Example String and Parameter Functions


Name Comments
filename The full pathname or the pathname relative to the script folder.
output parameter name The name of the parameter that stores the file contents.
continue on error lr.EXIT_VUSER (0) or

lr.read_file 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 is not applicable to this function.


These actions show the usages of lr.read_file.

public int action() throws Throwable {
    lr.read_file("test.txt","testparam", lr.EXIT_ACTION_AND_CONTINUE);
    // If file read, outputs file content. If not found or not read, outputs: {testparam}
    //not found with error
    lr.read_file("notfound.txt","notfound", lr.EXIT_VUSER);
    /* Log output:
       Error: can not open file
       Abort was called from an action.
       Ending Vuser...
    return 0;
}//end of action