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 - untyped generic object data type http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 untyped             Generic object data type
------------------------------------------------------------------------------
 Syntax
   untyped

 Arguments
   None.

 Features
   +----------------------------------------------------------------------+
   | Category             | special                                       |
   | Size                 | N/A                                           |
   | Range                | N/A                                           |
   | Parameter: value     | yes                                           |
   | Parameter: reference | yes                                           |
   | Parameter: const     | yes                                           |
   | Return               | no                                            |
   +----------------------------------------------------------------------+

 Description
   The untyped data type is for referring objects whose type is
   indeterminate. This data type is mostly used in parameter declarations,
   when more than one data type must be possible to pass, or an implicit
   data type conversion is necessary, or a non-parameterizable data type
   (like and index alias) needs to be passed.

   An untyped parameter is most frequently passed by reference, and the
   called function processes it as a void pointer (a pointer to any data
   object). If the receiver function is written in Force, then it must
   be in a separate module, and should not declare the passed parameter
   as untyped, but it must have a definite data type instead.

 Example
   #define EXAMPLE_DATATYPE
   #include example.hdr

   // Pass any object as an untyped by reference to the GetPtr() user-defined
   // function, which however receives the address of the object on the stack
   // as a ulong value. This method of producing a pointer is superseded
   // by the & operator and the addr() function.
   
   /*
   
   // This function body should be placed in a different module.
   
   func ulong GetPtr
   param value ulong xObject
   return( xObject )
   endfunc
   
   */
   
   func ulong GetPtr extern
   param untyped xObject
   
   proc Test_untyped
   vardef
      char cString
   enddef
   ? dechex( GetPtr( cString ) )  // hex address of cString
   ? dechex( &cString )           // prints identical value
   endproc

   proc main
   Test_untyped()
   endproc

See Also: ptr()

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