Constructor
new Variable(varDataopt)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
varData |
<optional> |
The optional initial content of the variable. |
- Source:
Methods
add(val)
Add the given number to the variable value
Parameters:
Name | Type | Description |
---|---|---|
val |
the number to add |
- Source:
addChild(childName, childVariable)
Add a child variable with the specified name.
If there is an existing child variable with this name, it is erased.
Parameters:
Name | Type | Description |
---|---|---|
childName |
The name of the variable to add |
|
childVariable |
The variable to add as a child |
Returns:
Type | Description |
---|---|
The variable (for chaining calls) |
- Source:
clearChildren()
Remove all the children.
If the variable is not a structure, nothing is done.
- Source:
concatenate(str)
Concatenate the given string at the end of the variable value
Parameters:
Name | Type | Description |
---|---|---|
str |
the string to append |
- Source:
div(val)
Divide the variable value by the given number
Parameters:
Name | Type | Description |
---|---|---|
val |
the divisor |
- Source:
getAllChildren()
Return the object containing all the children of the variable
Returns:
Type | Description |
---|---|
All the children of the variable |
- Source:
getAsNumber()
Get the value of the variable, considered as a number
Returns:
Type | Description |
---|---|
The number stored in the variable |
- Source:
getAsString()
Get the value of the variable, considered as a string
Returns:
Type | Description |
---|---|
The string stored in the variable |
- Source:
getChild()
Get the child with the specified name.
If the variable has not the specified child, an empty variable with the specified name is added as child.
Returns:
Type | Description |
---|---|
The child variable |
- Source:
hasChild()
Return the child in a variable.
Check if the variable has the specified children
Returns:
Type | Description |
---|---|
true if variable has the children with the specified name |
- Source:
isNumber()
Return true if the variable is a number.
Returns:
Type | Description |
---|---|
true if the variable is a number. |
- Source:
isStructure()
Return true if the variable is a structure.
Returns:
Type | Description |
---|---|
true if the variable is a structure. |
- Source:
isUndefinedInContainer()
Check if the variable must be considered as not existing in its container (usually a gdjs.VariablesContainer).
Returns:
Type | Description |
---|---|
true if the container must consider that the variable does not exist. |
- Source:
mul(val)
Multiply the variable value by the given number
Parameters:
Name | Type | Description |
---|---|---|
val |
the factor |
- Source:
removeChild(childName)
Remove the child with the specified name.
If the variable has not the specified child, nothing is done.
Parameters:
Name | Type | Description |
---|---|---|
childName |
The name of the child to be removed |
- Source:
replaceChildren(newChildren)
Replaces all the children with a new map of children.
Parameters:
Name | Type | Description |
---|---|---|
newChildren |
The map of new children. |
- Source:
setNumber(newValue)
Change the value of the variable, considered as a number
Parameters:
Name | Type | Description |
---|---|---|
newValue |
The new value to be set |
- Source:
setString(newValue)
Change the value of the variable, considered as a string
Parameters:
Name | Type | Description |
---|---|---|
newValue |
The new string to be set |
- Source:
setUndefinedInContainer()
Used (usually by gdjs.VariablesContainer) to set that the variable must be considered as not existing in the container.
- Source:
sub(val)
Subtract the given number to the variable value
Parameters:
Name | Type | Description |
---|---|---|
val |
the number to subtract |
- Source: