How to initialise STRUCT RESOURCE members

<struct-initialiser>

struct-initialiser ::=

<struct-name> { <struct-initialiser-item-list> } <struct-initialiser-item>

struct-initialiser-item ::=

<member-name> = <initialiser> ;

To initialise a member of STRUCT type, give the struct-name with which you wish to initialise it, and then specify each member of that struct which you wish to initialise.

The member-names listed must be members of the struct-name struct. Each initialise must be of a type compatible with the member it is initialising.

Example

Given the previously defined struct types,

STRUCT STRINGCOUNT
 {
 BUF message;
 WORD num;
 }
STRUCT SAMPLE
 {
 WORD anynumber;
 STRUCT text; // should be a STRINGCOUNT 
 }

the following example shows how to define the struct within a resource:

RESOURCE SAMPLE show_how
 {
 anynumber=10;
 text=STRINGCOUNT
  {
  message="Hello"
  num=5;
  };
 }

Type safety

The compiler does not enforce type safety. Any struct can be used to initialise a member declared to be of struct type. Usually, however, the designer of the struct will have intended only one or a limited number of structs ever be used to initialise a member. You should ensure that you initialise struct members with the intended struct type.