SoFunction
Updated on 2025-04-14

WAP website building WML language grammar basic tutorial page 5/6


2.3.3 Variables
Variables can be used in WML programming, and variables must be defined before use. Once a variable has been defined on one of the cards in the Deck, the other cards can be called directly without redefining it.
The syntax format for defining variables is:
$identifier
$(identifier)
$(identifier:conversion)
where identifier refers to the variable name, or variable identifier; conversion refers to the substitution of variables.
Variable names are composed of US-ACSII codes, underscores, and numbers, and can only start with US-ACSII codes. Variable names are strictly case sensitive, that is, variable names are case sensitive.
The syntax for defining variables enjoys the highest interpretation priority in WML.
The instructions for using variables are as follows:
1) In WML, variables can be used in strings, and the value of the variable can be updated during runtime.
2) When the variable is equivalent to an empty string, the variable will be in an unset state, that is, empty (Null).
3) When the variable is not equal to an empty string, the variable will be in the set state, that is, the non-null state.
4) In the form of "$identifier", WML usually indicates the end of the variable name with a space after the variable name. If in some cases the space cannot represent the end of a variable name, or the variable name contains spaces, the variable name must be enclosed in parentheses, that is, in the form of "$(identifier)".
Variables in WML programs can be replaced, and we can assign the value of the variable to a text in the Card. The following descriptions of variable substitutions:
1) In WML programs, only text parts can be replaced.
2) Substitution usually occurs during the runtime, and substitution will not affect the current value of the variable.
3) Any tag is implemented in a string substitution way.
4) Substitution is implemented in the form of string substitution.
Since variables have the best priority in syntax, strings containing variable declaration characters will be treated as variables, so if you want to make the program display the "$" symbol, you need to use two "$" in succession for explanation. For example: <p> Your acconut has $$15.00 in it </p>The result displayed by one sentence is: Your account has $15.00 in it.
2.3.2. WML core data type
The core data types of WML are all character-type data, and are defined according to the XML data types. There are 2. Noisy stops? 1) CDATA type. This data type is the most commonly used WML, and can be a number, a string or a string containing a number. However, when defining, whether it is a number or a string, it must be defined in text form and the data is enclosed in quotes. CDATA type data is only used for attribute values. For example, "$(value)" or name="value" etc. Note that the value here refers to the data value of the CDATA type.
2) PCDATA type. This is a type of data decomposed from CDATA. In addition to being a number, a string or a mixed string of both, it can also be a WML tag. PCDATA type data can only be used for element representation of WML.
3) NMTOKEN type. This is a special type of data. All data containing or part of numbers, letters and punctuation marks belong to NMTOKEN type data. This kind of data can be started with punctuation, but is not used to define variable names or element names.
4) Id type. A data type specifically used to define the name of a WML element.
In this 2. Noisy elliptical DATA type is more flexible to use, it can save variables or data from syntax checking. This is because the data content in CDATA will be processed as text, which can avoid WML grammar checking and directly display it as text.
Previous page123456Next pageRead the full text