Share this page

# lr.redirect

Redirects a string to a file.

    int lr.redirect( String file_name, String str, boolean append);

Message Functions

## Arguments

Name | Comments
--- | ---
file_name | The file to which to redirect the string. If the file does not exist, it creates a new file. If the file does exist, it appends it to the file or overwrite the file (see the append argument)
str | The string to redirect.
append | An optional flag indicating whether to overwrite the specified file, or to append the string to the file. "false" indicates to overwrite the file. "true", the default, indicates to append the string to the file.

The lr.redirect function redirects a Java string to a file. If the specified file does not exist, VuGen creates the file. If it does exist, you can indicate whether to append or overwrite the file. By default, VuGen appends to the file.

To allow redirection, you need to enable redirection using the lr.enable_redirection function.

## Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure. Note that in many cases, this return value indicates the technical success of the function, and not the result. For example, a function that registers a string to be found in a subsequent step returns LR_PASS to indicate that the registration was successful. This does not indicate that the string was found in the server response.

## Parameterization

You cannot use standard parameterization for any arguments in this function.

## Example

In the following example the lr.redirect function instructs VuGen to redirect the Java output and error streams to the my_messages.txt file.

Copy code

    int rc;
    lr.enable_redirection(true);

    /* Overwrite the file if it exists. If there is no file, create it.
        If there is no "K" drive, the redirect fails. */
    rc = lr.redirect ("K:\\temp\\my_messages.txt",
        "Application running!", false);

    if ( rc == lr.FAIL )
    {
        /* Append the string to the local error file if it exists.
            If there is no file, create it. */
        lr.redirect("d:\\temp\\VuGen_err.txt",
            "Redirect failed!");
    } else // Redirect succeeded.
    {
        /* Write to the message to redirect
            target file on K: */
        lr.redirect("K:\\temp\\my_messages.txt",
            "Redirect succeeded!");
    }
    lr.enable_redirection(false);

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: