RTNDATA Statement

Returns data to the RTNDATA clause of a PERFORM statement.

Syntax

RTNDATA expression

Syntax Elements

expression is any valid DataBasic expression or any string, substring, or value; expressed as a variable name, a value, a dynamic array, or a string enclosed in quotes.

Operation

The RTNDATA statement is used in conjunction with the PERFORM statement. It is assumed that the reader is familiar with the operation of the PERFORM statement in this description.

The RTNDATA statement is only used in a program that has been PERFORMed by another program. The expression specified is passed back to the calling program and assigned to the variable specified by the RTNDATA clause of the PERFORM statement. If no RTNDATA clause is used, then the data is discarded.

Comments

Use of the RTNDATA statement in a program that has not been PERFORMed is meaningless. In this case, the data is lost.

Example

   PROG1
001 NUM=50
002 PERFORM 'RUN BP PROG2' PASSDATA NUM RTNDATA SQRT
003 PRINT 'THE SQUARE FOOT OF ':NUM:' IS ':SQRT
   PROG2
001 COLLECTDATA NUMBER
002 SQUAREROOT = SQRT (NUMBER)
003 RTNDATA SQUAREROOT

In this example PROG1 is run. It performs PROG2 and passes the numeric value 50. When PROG2 is executed, the COLLECTDATA statement in line 001 retrieves the data passed by the PASSDATA clause in PROG1 and stores it in the variable NUMBER. Line 002 in PROG2 gets the square root of the value NUMBER and assigns it to the variable SQUAREROOT. Line 003 returns the value of SQUAREROOT back to the calling program (PROG1) and stores the value in the variable SQRT.