
// View Widget Definitions
#define getCnt
cnt.value
// Control Widget Definitions
#define cntTo0x00
cnt.setValue(0x00)
#define setCnt cnt.setValue
|
Where: |
|
|
|
// Global Definitions is a comment |
|
|
#define allows text substitutions during compilation. |
|
|
cntIndex is the variable name, which can be used within myVariables.txt and any project that includes myVariables.txt. |
|
|
0 is the text which will replace any instances of the token cntIndex. |
Notice that the second variable cnt, references the first variable
cntIndex. This will result in any instance of the token cnt being
replaced with the following string: Amulet:InternalRAM.byte(0). In this
example, we are using cntIndex to represent the InternalRAM byte variable
index. So, all the buttons are setting InternalRAM byte variable 0 and the Numeric
Field is reading InternalRAM byte variable 0. If cntIndex was changed to another
number, all the buttons and the Numeric Field would automatically use the appropriate
InternalRAM byte variable.
To create a numeric field named fldCounter that uses a variable named getB0 as its href, the following is used:
<APPLET CODE="Field.class" WIDTH="95" HEIGHT="25" NAME="fldCounter">
<PARAM NAME="href" VALUE="getCnt()">
<PARAM NAME="min" VALUE="0">
<PARAM NAME="max" VALUE="255">
<PARAM NAME="printf" VALUE="InternalRAM.byte(0) = %02x">
<PARAM NAME="minFld" VALUE="0">
<PARAM NAME="maxFld" VALUE="255">
<PARAM NAME="fontSize" VALUE="3">
<PARAM NAME="fontStyle" VALUE="bold">
<PARAM NAME="verticalAlign" VALUE="middle">
<PARAM NAME="horizontalAlign" VALUE="center">
<PARAM NAME="border" VALUE="1">
<PARAM NAME="updateRate" VALUE=".33">
</APPLET>
During compilation, the Amulet HTMLCompiler preprocessor will substitute the text Amulet:InternalRAM.byte(0) for every occurrence of the variable getCnt
present in a META, HREF, INITHREF, ONVAR, URL link, preprocessor include
file or initInternalRAM include file throughout the entire HTML project. Because
getCnt is defined as cnt.value in myVariables.txt, fldCounter's href
is really requesting Amulet:InternalRAM.byte(0).value()
every 330 msec because the preprocessor substitutes the text in for the variable getCnt at compile time.
The function buttons also use variable names for their href functions. Here is the source for one of the buttons:
<APPLET CODE="FunctionButton.class" WIDTH="63"
HEIGHT="25" NAME="Btn80">
<PARAM NAME="href"
VALUE="setCnt(0x80)">
<PARAM NAME="fontSize" VALUE="3">
<PARAM
NAME="fontStyle" VALUE="bold">
<PARAM NAME="label"
VALUE="0x80">
<PARAM NAME="buttonType" VALUE="spring-loaded">
<PARAM
NAME="onButtonPress" VALUE="depress">
<PARAM NAME="repeatDelay"
VALUE="1.5">
<PARAM NAME="repeatRate" VALUE="0.5">
</APPLET>
The href function of B0to0x80 is defined in myVariables.txt as
To see how easy it is to modify a constant in an include file, try editing the textual substitution to request a different UART variable in the myVariables.txt file in a text editor. Better yet, try adding a new constant definition. Reference the preprocessor documentation for more info regarding the syntax to use when defining a constant. Be sure to save any changes you make to the include file. Don't forget to either edit the existing numeric field widget or add a new widget in CompileMe.htm which references the new constant. Then, use the HTMLCompiler to recompile CompileMe.htm and program the HTML page into the Easy GUI module.
NOTES: