| **Navigation:**  [[introduction.htm|Language Reference]] > App E - Legacy Statements >====== FUNCTION (define a function) {{c6h0007.jpg|C6H0007.jpg}} ====== | [[eof return end of file .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[pointer return relative record position .htm|{{btn_next_n.gif|Next page}}]] | | || | //label// | **FUNCTION** [**(**//parameter list//**)**] | | | //local data// | | | **CODE** | | | //statements// | | | **RETURN(**//value//**)** | {{blk2blue.jpg|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) &   & Last)  ! return full name** ** ELSE                  !Otherwise** **  RETURN(CLIP(First) &   & Init & .  & 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 define a procedure .htm|PROCEDURE]]