| BASIC CODE: FUNCTION |
| Example of the FUNCTION and DEFFUN commands versus the SUBROUTINE and CALL commands. |
|
|
| Code Example |
|
| ---File this as a program called DOZ.CONVERT: |
| function DOZ.CONVERT(NMBR, DIRECTION) |
| if DIRECTION = 'TO.DOZ' then RESULT = NMBR/12 else RESULT = NMBR * 12 |
| return(RESULT) |
|
| ---File this as a program called DOZ.SBR: |
| subroutine DOZ.CONVERT(NMBR, DIRECTION) |
| if DIRECTION = 'TO.DOZ' then NMBR = NMBR/12 else NMBR = NMBR * 12 |
| return |
|
| ---File this as a program called TEST.DC: |
| DEFFUN DOZ.CONVERT(VALUE,DIR) |
| CRT DOZ.CONVERT(12,'TO.DOZ') |
| CRT DOZ.CONVERT(12,'TO.UNITS') |
| * |
| QTY = 12 |
| CALL DOZ.SBR(QTY,'TO.DOZ') |
| CRT QTY |
| CALL DOZ.SBR(QTY,'TO.UNITS') |
| CRT QTY |
| CALL DOZ.SBR(QTY,'TO.UNITS') |
| CRT QTY |
| STOP |
| --- |
| The results will be an output of 1,144,144,12,1. |
|
| Synonyms |
|
| See also |
CALL
| SUBROUTINE
| FUNCTION
| DEFFUN
|
| Categories |
ALL
| BRANCHING
|
More Details or Suggestions?
|
Updated from a Post-Relational data table on 10:18:30 23 Apr 2010
Courtesy of Key Ally, Inc.
More information at U2-Users Group
UniVerse is a Trademark of Rocket Software. Previous, IBM, Informix, Ardent, and vMark.
DMOZ
Wikipedia
|