Share this page

# return

    return [ expression ];

Causes the current function to terminate. It can return a value to the calling function. A return statement can appear in a function whose return type is void. If the value returned has a type different from that of the function's return type, then the value is converted. Using the return statement without an expression creates an undefined result. Reaching the brace } at the end of the function is the same as returning without an expression.

For action functions, return one of the following values:

0: Iterate normally. Control flow will go to the next action specified in the run logic.

-1: Exit script and permanently stop this VUser.

1: Exit this iteration.

## Example

The following example allocates a memory buffer using the malloc function. If allocation is unsuccessful, the function returns with a -1 value. If successful, the function continues and returns 0 at completion.

        #include <malloc.h>
        char * buf;
        if ((buf = (char *)malloc(1024, sizeof(char))) == NULL) {
            lr_output_message ("Insufficient memory available");
            return -1;
        }

        lr_output_message ("Memory allocated - buffer address = %.8Xh", buf);

        // Do something with the buffer here ...

        // Now free the buffer

        free(buf);

    Example: Output:
    Action.c(11): Memory allocated - buffer address = 007B9D88h

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