A variable can have one of the following types:
-
NUMBER
-
STRING
-
MAP (associative array)
-
ARRAY
Declarations
Variables of different types are declared differently in HSP. NUMBER and STRING variables are declared automatically, when they are used for the first time.
Only MAP and ARRAY variables must be declared explicitly.
A variable name MUST start with a letter or underscore character, can contain letters, numbers or the underscore character and can have a maximum length of 255 characters.
Types of Variable Values
-
Type NUMBER
Values of the variables that have this type must follow the regular expression:
-
Type STRING
Strings are defined as follows:
-
Type ARRAY
Elements of an array can have any of the HSP types (NUMBER, STRING, MAP or ARRAY). Each array element is uniquely identified by an index. These are the actions you can perform on an element of an array:
-
access
-
modify
-
push (add an element at the end of an array)
-
pop (fetch the element from the end of an array – the array becomes one element shorter)
The access to an element of an ARRAY must use the following the expression:
-
Type MAP
Elements of a map can have any of the HSP types. You can access, modify, or insert an element of a map.
The access to an element of a MAP must use the expression: