Calling within an Expression

If a prototyped procedure is defined to return a value then you must call the procedure within an expression if you want to make use of the return value. Use the procedure name in a manner that is consistent with the data type of the specified return value. For example, if a procedure is defined to return a numeric, then the call to the procedure within an expression must be where a numeric would be expected.

Figure 63 shows the prototype for a procedure CVTCHR that takes a numeric input parameter and returns a character string. Figure 64 shows how the procedure might be used in an expression.

Figure 63. Prototype for CVTCHR
      * Prototype for CVTCHR
      * - returns a character representation of the numeric parameter
      * Examples:   CVTCHR(5) returns '5                    '
      *             CVTCHR(15-124) returns '-109                   '
     D CVTCHR          PR            31A
     D   NUM                         30P 0   VALUE
Figure 64. Calling a Prototyped Procedure within an Expression
     C                   EVAL      STRING = 'Address: ' +
     C                                      %TRIM(CVTCHR(StreetNum))
     C                                      + ' ' + StreetName
      * If STREETNUM = 427 and STREETNAME = 'Mockingbird Lane', after the
      * EVAL operation STRING = 'ADDRESS: 427 Mockingbird Lane'


[ Top of Page | Previous Page | Next Page | Contents | Index ]