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 - return return control to calling code http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 return              Return control to calling code
------------------------------------------------------------------------------
 Syntax
   return[(][ <expression> ][)]

 Arguments
   <expression> is the value returned from a function.

 Description
   The return statement is used to terminate a function and return
   control to the statement following the call to that function. The return
   statement is also used to return a value from functions, while procedures
   can not return a value.

   The data type of the returned value must match the type of the function
   as declared in its prototype. Some complex data types may not be legally
   returned. In such cases however pointers to that data type can sometimes
   be applied as the return value.

   Although it is not a recommended practice, it is possible to return from
   multiple places in a function. However, a function can return only one
   single value at one call to it. This limitation can be overcome by
   passing appropriate parameters by reference to the function, then change
   their value. In this case the calling code can utilize the effect of
   the function in more than one respect.

 Example
   #define EXAMPLE_STATEMEN
   #include example.hdr

   func uint Test static
   param value uint uValue
   uValue += 50
   return( uValue )
   endfunc
   
   proc Test_return
   vardef
      uint uNum
   enddef
   uNum := 5
   ? uNum
   if uNum < 2
      ? "Exit prematurely"
      return
   endif
   ? Test( uNum )
   ? "End of program"
   endproc

   proc main
   Test_return()
   endproc

See Also: endfunc endproc func proc

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