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 - const constant data type modifier http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 const               Constant data type modifier
------------------------------------------------------------------------------
 Syntax
   <func>
   param const <datatype> <var>

 Arguments
   <func> is a function or procedure declaration.
   <datatype> is the data type of the parameter.
   <var> is the symbol name of the parameter variable.

 Description
   The const data type modifier is used in parameter declarations to ensure
   that the object it applies to is not modified by the function. The
   compiler issues a syntax error when attempting to assign a value to a
   parameter passed as a constant.

   Parameters having the const modifier are passed by reference.
   When passing a parameter by reference, the 4-byte address of the
   underlying memory object is placed on the stack at function call
   time. Using the address instead of the value itself is advantageous
   only when the size of the data object well exceeds 4 bytes.
   Therefore the use of the const modifier with non-char parameters
   is not recommended; use of the value modifier is preferred instead.

 Example
   #define EXAMPLE_KEYWORD
   #include example.hdr

   proc PrintString
   param const char cString
   ? cString
   endproc
   
   proc Test_const
   PrintString( "Hello world" )
   endproc

   proc main
   Test_const()
   endproc

See Also: param value

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