|
1 <?xml version="1.0" encoding="utf-8"?> |
|
2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. --> |
|
3 <!-- This component and the accompanying materials are made available under the terms of the License |
|
4 "Eclipse Public License v1.0" which accompanies this distribution, |
|
5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". --> |
|
6 <!-- Initial Contributors: |
|
7 Nokia Corporation - initial contribution. |
|
8 Contributors: |
|
9 --> |
|
10 <!DOCTYPE concept |
|
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
|
12 <concept id="GUID-32F00078-6084-5288-9D3F-9F8D70514799" xml:lang="en"><title>RESOURCE |
|
13 statement</title><prolog><metadata><keywords/></metadata></prolog><conbody> |
|
14 <codeblock xml:space="preserve"><resource-statement> |
|
15 resource-statement ::= |
|
16 RESOURCE <struct-name> [ <resource-name> ] { <resource-initialiser-list> } </codeblock> |
|
17 <p>The <codeph>RESOURCE</codeph> statement is used to generate a resource |
|
18 in the resource file. The statement specifies three things:</p> |
|
19 <ul> |
|
20 <li id="GUID-F51FD208-5879-57EF-9E16-914A1F4F1FE7"><p>a <varname>struct-name</varname> which |
|
21 denotes the structure that will be used for the resource</p> <p>It must have |
|
22 been defined in a previous <codeph>STRUCT</codeph> statement and must be in |
|
23 upper case.</p> </li> |
|
24 <li id="GUID-1EE96D74-26D0-5BC3-8EDC-19CD924515D0"><p>an optional <varname>resource-name</varname> which |
|
25 identifies the resource</p> <p>The <codeph>resource-name</codeph> must be |
|
26 in lower case.</p> <p>The <codeph>resource-name</codeph> causes a symbolic |
|
27 constant to be generated in the resource compiler’s output header file, so |
|
28 that a resource</p> <codeblock id="GUID-505C63EA-20A4-5019-BA34-FEAED516E037" xml:space="preserve">RESOURCE TEST my_test { /* etc */ }</codeblock> <p>will |
|
29 result in a definition of the form</p> <codeblock id="GUID-4FBB0DF1-09D6-54CA-AAD4-F29BFCC27A42" xml:space="preserve">#define MY_TEST 1</codeblock> <p>in |
|
30 the generated header file.</p> <p>The default ID for the first resource defined |
|
31 in the file is one with subsequent resources’ IDs generated in ascending sequence. |
|
32 See <xref href="GUID-F9605837-2209-500D-AB62-48A433489C5E.dita">Resource file definition</xref> for |
|
33 more information on how resource IDs are generated.</p> <p>If no resource |
|
34 name is specified then the resource is generated in the object file and assigned |
|
35 a resource ID as usual, but will not be published in the header file. Anonymous |
|
36 resources are used mainly for playback scripts where the resources are read |
|
37 in sequentially by default, so that assigning names to them would be superfluous.</p> <p>The <codeph>resource-name</codeph> may |
|
38 also be used by the resource compiler for <codeph>LINK</codeph> and <codeph>LLINK</codeph> members |
|
39 — see <xref href="GUID-FFD56DA3-9301-5679-9209-A70CE63A34A2.dita">Resource identifiers |
|
40 for LINKs and LLINKs</xref>.</p> </li> |
|
41 <li id="GUID-4F0ED7DA-1A16-53FE-A1E0-98298A9B2BB0"><p>initialisation for members |
|
42 of the resource struct, where their default values are not appropriate</p> </li> |
|
43 </ul> |
|
44 <example><p>As an example, given the struct definition</p><codeblock id="GUID-D2FBD433-0A85-5C0C-9CD2-CFC08F20E14E" xml:space="preserve">STRUCT NCEDIT |
|
45 { |
|
46 WORD current; |
|
47 WORD low; |
|
48 WORD high=65535; |
|
49 }</codeblock><p>you could define a resource:</p><codeblock id="GUID-4B005C45-B0EF-542D-BD63-0D2E02186FFA" xml:space="preserve">RESOURCE NCEDIT memory_size |
|
50 { |
|
51 low=640; |
|
52 high=1024; |
|
53 }</codeblock><p>Thus, in the resource file, <codeph>current</codeph> has |
|
54 the value compiler default value of 0, <codeph>low</codeph> has the value |
|
55 640 (specified in the resource definition) and <codeph>high</codeph> has the |
|
56 value 1024 (specified in the resource definition, overriding the default for |
|
57 the struct type).</p></example> |
|
58 </conbody></concept> |