User Tools

Site Tools


function_define_a_function_.htm
Navigation:  Language Reference > App E - Legacy Statements >====== FUNCTION (define a function) C6H0007.jpg ====== Previous pageReturn to chapter overviewNext page
label FUNCTION [(parameter list)]
local data
CODE
statements
RETURN(value)

blk2blue.jpg

FUNCTION is a statement which once defined a PROCEDURE prototyped to return a value (referred to as a function in some other programming languages). The FUNCTION keyword has been replaced by the PROCEDURE statement and is now a synonym for PROCEDURE in all cases.

Example:

PROGRAM

MAP

FullName FUNCTION(STRING Last,STRING First,<;STRING Init>),STRING

                                 !Function prototype with parameters

DayString FUNCTION,STRING         !Function prototype without parameters

END

TodayString STRING(3)

CODE

TodayString = DayString()        !Function call without parameters

                                 ! the () is required for a function

FullName FUNCTION(STRING Last, STRING First,STRING Init)    !Full name function

CODE                             !Begin executable code section

IF OMITTED(3) OR Init =          !If no middle initial

 RETURN(CLIP(First) &amp;   &amp; Last)  ! return full name

ELSE                  !Otherwise

 RETURN(CLIP(First) &amp;   &amp; Init &amp; .  &amp; Last)                ! return full name

END    

DayString   FUNCTION              !Day string function

ReturnString STRING(9),AUTO       !Uninitialized local stack variable

CODE                             !Begin executable code section

RETURN(CHOOSE(TODAY()%7)+1,Sun,Mon,Tue,Wed,Thu,Fri,Sat))

See Also:

PROCEDURE

function_define_a_function_.htm.txt · Last modified: 2021/04/15 15:57 by 127.0.0.1