<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License
"Eclipse Public License v1.0" which accompanies this distribution,
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
Nokia Corporation - initial contribution.
Contributors:
-->
<!DOCTYPE concept
PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-97C0A5B1-99AE-5F71-9092-A6976E54AEA7" xml:lang="en"><title>How
to initialise STRUCT RESOURCE members</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p><i><codeph><struct-initialiser></codeph></i>
</p>
<p><b>struct-initialiser ::=</b>
</p>
<p><i><codeph><struct-name></codeph></i><b> {</b> <i><codeph><struct-initialiser-item-list></codeph></i> <b>}</b> <i><codeph><struct-initialiser-item></codeph></i>
</p>
<p><b>struct-initialiser-item ::=</b>
</p>
<p><i><codeph><member-name> = <initialiser> ;</codeph></i></p>
<p>To initialise a member of <codeph>STRUCT</codeph> type, give the <varname>struct-name</varname> with
which you wish to initialise it, and then specify each member of that struct
which you wish to initialise.</p>
<p>The <varname>member-name</varname>s listed must be members of the <varname>struct-name</varname> struct.
Each <varname>initialise</varname> must be of a type compatible with the member
it is initialising.</p>
<p><b>Example</b> </p>
<p>Given the previously defined struct types,</p>
<codeblock id="GUID-B7A47237-F871-5A07-B97B-11034F7019D1" xml:space="preserve">STRUCT STRINGCOUNT
{
BUF message;
WORD num;
}</codeblock>
<codeblock id="GUID-562D9436-F734-5E07-B452-08BD40F08959" xml:space="preserve">STRUCT SAMPLE
{
WORD anynumber;
STRUCT text; // should be a STRINGCOUNT
}</codeblock>
<p>the following example shows how to define the struct within a resource:</p>
<codeblock id="GUID-425AD6B0-750B-56C2-8643-2726904C7DB7" xml:space="preserve">RESOURCE SAMPLE show_how
{
anynumber=10;
text=STRINGCOUNT
{
message="Hello"
num=5;
};
}</codeblock>
<p><b>Type safety</b> </p>
<p>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.</p>
</conbody></concept>