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 - typedef struct structure declaration block http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 typedef struct      Structure declaration block
------------------------------------------------------------------------------
 Syntax
   typedef struct <structtype>
      <datatype> <member>
      ...
      <datatype> <member>
   enddef

 Arguments
   <structtype> is the type name of the structure.
   <datatype> is the member data type.
   <member> is an object participating in the structure aggregation.

 Description
   The typedef struct keyword initiates a structure declaration block.
   A structure is an aggregate data type. It allows multiple data objects to
   be grouped together and referred using one symbol name. Each object in a
   structure is called a member and may have any primitive data type,
   including pointers and arrays.

   Structures can be viewed as arrays whose elements (members) are of
   different types. Structure members can be initialized in non-local
   vardef blocks. At initialization members are separated by commas,
   array members are surrounded with {} delimiters.

   Declared structure types become a new derived data type. Data objects
   belonging to that structure type can be declared the same way as
   primitive data types, using the structure type name as their data
   type. Defined structure type names are case insensitive.

   Structure members are referred to using the '.' member operator.
   Members can be passed by value or address. Structures can be passed to
   functions as by-reference parameters, but can not be directly returned
   from functions.

   It is recommended to declare char members with explicit length
   specification to avoid unnecessarily big structures in memory, similarly
   to the case of string arrays.

   The combined length of the <structvar>.<member> construct may not exceed
   the maximum symbol name length, that is 32 characters. The dot member
   operator (.) and any array indexing brackets contribute to the
   length.

   In the current version of Force some limitations apply to structures.
   Structures can not be nested, that is a structure can not contain another
   structure as its member. The ptr( struct ) data type may not occur as
   a structure member. Structures can not be placed in an array.

   Different structures can be based on each other, but the members of a
   particular structure can not be based on each other.


 Example
   #define EXAMPLE_KEYWORD
   #include example.hdr

   typedef struct TESTSTRUCT
      char( 40 ) cName
      char( 15 ) cPhone[ 2 ]
      uint       nAge
      dbl        eBalance
   enddef
   
   vardef static
      TESTSTRUCT sTest := "Jeannie Towall", ;
                          { "(232) 456 7682", "(224) 492 0087" }, ;
                          22, -11231
   enddef
   
   proc Test static pascal
   param TESTSTRUCT sData
   ? sData.cName
   ? sData.cPhone[ 0 ]
   ? sData.cPhone[ 1 ]
   ? sData.nAge
   ? sData.eBalance
   endproc
   
   proc Test_typedefstruct
   Test( sTest )
   endproc

   proc main
   Test_typedefstruct()
   endproc

See Also: .

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