This command is used to control variable assignments. It contains three special attributes: name, expression, and type. Data in expression is used to assign a value to the variable in name. The attributes condition, delay, and delayCondition are the same as those in <Command>.
<VariableCommand name="" expression="" type="" condition="" delay="" delayCondition=""/>
Parameter | Type | Mandatory | Description |
|---|---|---|---|
name | String | Yes | Variable name. |
expression | Expression | Yes | Expression used to assign a value (which can be a constant) to a variable. Variables cannot be defined using expressions, such as #countNum+5. |
type | String | No | Indicates whether a variable is of the string or number type. The default type is number. |
condition | Expression | No | Condition for command execution judgment. When the value is true or a non-0 number, the command is executed; when the value is false or 0, the command is not executed. |
delay | Number | No | Delay for executing a command, in milliseconds. |
delayCondition | Expression | No | Condition for command delay judgment. By default, when the value is true or 1, the command execution is delayed; when the value is false or a non-1 number, the command execution is not delayed. |
Run the variable assignment command.
<Button x="0" y="0" h="100" w="100">
<Trigger action="down">
<!--If second is smaller than 40, the variable assignment command is executed.-->
<VariableCommand name="delayCond0" expression="#delayCond0+5" condition="lt(#second,40)"/>
<!--If second is smaller than 40, the variable assignment command is delayed for 6000 ms.-->
<VariableCommand name="delayCond1" expression="#delayCond1+5" delayCondition="lt(#second,40)" delay="6000"/>
<!--If second is smaller than 40, that is, both execution condition and delay condition are true, the variable assignment command is delayed for 4000 ms.-->
<VariableCommand name="delayCond2" expression="#delayCond2+5" condition="lt(#second,40)" delayCondition="lt(#second,40)" delay="4000"/>
</Trigger>
</Button>