Assume that you run the following procedure:
PROCEDURE testReturn()
var x = 0
if (x == 0){
return "In the IF statement"
}
return "At the end of the procedure"
Your output will be: “At the end of the procedure”
From the VAIL Rule and Procedure Reference Guide you find the following definition of the RETURN statement:
RETURN
VAIL procedures return a value when their execution completes. By default, the return value is the value produced by the last VAIL statement to execute. In order to make return values more explicit the RETURN statement may be used to specify the returned value. However, the RETURN statement MUST be the last statement in the body of the procedure. The RETURN statement CANNOT be used to terminate execution of the procedure earlier in the procedure body.
In the example above, you might want to add an ELSE clause so that it looks like this:
PROCEDURE testReturnWithElse()
var x = 0
if (x == 0){
return "In the IF statement"
} else
{
return "At the end of the procedure"
}
When you run the above procedure the output will be “In the IF statement”.
Assume that you run the following procedure:
Your output will be: “At the end of the procedure”
From the VAIL Rule and Procedure Reference Guide you find the following definition of the RETURN statement:
RETURN
VAIL procedures return a value when their execution completes. By default, the return value is the value produced by the last VAIL statement to execute. In order to make return values more explicit the RETURN statement may be used to specify the returned value. However, the RETURN statement MUST be the last statement in the body of the procedure. The RETURN statement CANNOT be used to terminate execution of the procedure earlier in the procedure body.
In the example above, you might want to add an ELSE clause so that it looks like this:
When you run the above procedure the output will be “In the IF statement”.