Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Force 4.0 Reference - func function declaration or definition http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 func                Function declaration or definition
------------------------------------------------------------------------------
 Syntax
   func <type> <symbol> [<scope>]
   [ <params> ]
   [ <code> ]
   endfunc

 Arguments
   <type> is the data type of the return value of the function.
   <symbol> is the name of the function.
   <scope> is the range of visibility for the function.
   <params> is a parameter declaration.
   <code> is the body of code belonging to the function.

 Description
   The func keyword initiates a function declaration. A function
   contains executable code that serves as the main functional manifestation
   of the program. The flow of execution in a function is sequential, unless
   modified by iterative control statements (like do while), or calls to
   other functions.

   A function is executed when it is called from another piece of code.
   The invoked function receives information from the place of the call
   via its parameters. When the called function is finished, flow
   control is returned to the statement in the caller code that
   immediately follows the place of the original call. A function passes
   information back to the caller via the return statement. In
   fact the only difference between functions and procedures is that the
   latter ones do not return values.

   A special case is the main() function which is automatically called
   from the runtime startup code in force.lib when the application starts
   executing. All subsequent operations are governed by the statements
   in main(), including the function calls initiated in it.

 Example
   #define EXAMPLE_KEYWORD
   #include example.hdr

   func logical MsgAdd static
   param char cMsg
   vardef
      logical lChanged
   enddef
   lChanged := .f.
   if len( cMsg ) < 245
      cMsg += " world"
      lChanged := .t.
   endif
   return( lChanged )
   endfunc
   
   proc Test_func
   vardef
      char cMessage
   enddef
   cMessage := "Hello"
   if MsgAdd( cMessage )
      ? cMessage
   endif
   endproc

   proc main
   Test_func()
   endproc

See Also: () endfunc proc

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson