Using arrays - Pararock/QSPSaveEditor GitHub Wiki
QSP supports arrays. Array - a consistent set of values that have one data type and have the same name. The array elements are identified by the index. Indexing is carried out from the ground. Those. element with index 0 - the first element of the array, one - second, etc. Depending on the type of elements in the array, it can be text or numeric. The QSP each array has both text and numeric values. If you want to apply to text elements in an array, you need to put the name of his character "$" if a numeric - is enough to specify its name. Accessing an array element takes place as follows: first name of the array is specified (with the symbol "$" or without it), and then in brackets - a numeric expression equal to the index of the element to which accessed. Those. "$ A [6]" - a request to the text value of the element with index 6 (7th) array called "A", "NEW [2]" - a request to the numerical value of the element with index 2 (3rd) array called "NEW". The assignment of values and read the array is exactly the same as when using the variable. examples:
A[2] = 89 - assign the numeric value 89 to the third element of array A
$B[3] = 'Cool' - assign the string value Cool to the fourth element of array B
A = B[5] - assign a numeric value of the variable "A" the numerical value of the 6-element array "B"
$C = $MAS[54] - the same
Arrays can be indexed by string. The case of this string does not matter. examples:
$ARR['mystring'] = 'value' is equivalent to $arr['MyString'] = 'value'
ARR['mystring'] = 890
$Item_loc['stick'] = 'wood'
$DESCS[$curloc] = '<<$DESCS[$curloc]>> text.'
values['67'] = 87
In addition, there is a simplified syntax to add an element to the array - if the index is not specified, then the element will be selected following the last. For example:
$Objs[] = 'ax'
$Objs[] = 'Files'
$Objs[] = 'Board'
Upon receipt of the value if the index is not specified, the last item is selected. For example:
$A = $objs[]
a = objs[]
PS. All variables in QSP are arrays. A = 5
and A[0] =
are equivalent.