Symbian3/SDK/Source/GUID-97C0A5B1-99AE-5F71-9092-A6976E54AEA7.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 21 Jan 2010 18:18:20 +0000
changeset 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of Documentation_content according to Feature bug 1266 bug 1268 bug 1269 bug 1270 bug 1372 bug 1374 bug 1375 bug 1379 bug 1380 bug 1381 bug 1382 bug 1383 bug 1385

<?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>&lt;struct-initialiser&gt;</codeph></i>
</p>
<p><b>struct-initialiser ::=</b>
    </p>
<p><i><codeph>&lt;struct-name&gt;</codeph></i><b> {</b> <i><codeph>&lt;struct-initialiser-item-list&gt;</codeph></i> <b>}</b> <i><codeph>&lt;struct-initialiser-item&gt;</codeph></i>
</p>
<p><b>struct-initialiser-item ::=</b>
    </p>
<p><i><codeph>&lt;member-name&gt; = &lt;initialiser&gt; ;</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>