・Either VAR or DIM can be used.
・Multiple variables can be defined simultaneously by separating them with commas.
・Alphanumeric characters and underscores (_) can be used for variable names.
・You cannot use numbers at the beginning.
・The result of the expression becomes the initial value of the variable.
・If the expression is not specified, :Int type zero, #:Real type zero, $:empty string is set as the initial value by the type symbol (/#/$) at the end of the variable name.
・If the expression is not specified and the variable name has no type symbol, the default numeric type zero is set as the initial value.
VAR A=0,B,C DIM B$
・Either VAR or DIM can be used.
・If a type symbol (%/#/$) is added at the end of a variable name, an Int array, Real array, and string array are created respectively.
・If the type symbol is not specified, a default numeric type array is created.
・Specify the number of array elements to be secured with [].
・The number of elements can be created up to a 4D array by separating them with commas.
・If the number of elements is not specified, a 1D array with zero elements is created.
VAR ATR[4] VAR DX[5],DY[5],DZ[5] DIM POS$[10,5] DIM IMAGE[]
・Either VAR or DIM can be used.
・If a type symbol (%/#/$) is added at the end of a variable name, an Int array, Real array, and string array are created respectively.
・If the type symbol is not specified, a default numeric type array is created.
Specify the number of array elements to be secured with []
・The number of elements can be created up to a 4D array by separating them with commas.
・If the number of elements is not specified, a 1D array with zero elements is created.
List of values to set as initial values for array elements
・If the number of elements is not specified, the number of values is a 1D array of the number of elements.
VAR ATR[4]=[1,2,3,4] DIM POS$[10,5]=["X","Y","Z","W"] DIM IMAGE[]=[0,1,2,3,4]
・If OPTION STRICT is not defined, the variable is automatically defined when trying to assign to an undefined variable.
・If OPTION STRICT is defined, an Undefined Variable error will occur when trying to assign to an undefined variable.
A=10 B=A*6 C[4]=A+B
Two variables whose values are to be exchanged
SWAP A,B SWAP A[5],B[2]
Variable to manipulate
The value to add
・If not specified, it's 1.
INC X INC X,3
Variable to subtract
The value to subtract
・If not specified, it's 1.
DEC X DEC X,3
Copy source array
・Only 1D arrays can be specified.
First element number of copy source
・If not specified, it's 0.
Number of elements to copy
・If not specified, the number of elements in the copy source array minus the copy source offset is specified.
Copy result array
・In the case of string array, the string of each element is also copied.
Copy source string
Copy source start position
・If not specified, it's 0.
Number of characters to copy
・If not specified, the number of characters in the copy source string minus the copy source offset is specified.
Copy result string
・For 1D arrays only, if the copy destination array has fewer elements than the copy source array, it is automatically expanded.
・The dimensions of the array are ignored for both the copy source and the copy destination.
Copy destination array
First element number of the copy destination
・If not specified, it's 0.
Copy source array
First element number of copy source
・If not specified, it's 0.
Number of elements to copy
・If not specified, the number of elements in the copy source array minus the copy source offset is specified.
DIM SRC[10],DST[10] COPY DST,SRC
・Read the data defined by the DATA statement into the array.
・If the number of array elements is less than the number of copy data, only 1D arrays are automatically expanded if the number of elements in the copy destination array is insufficient.
Copy destination array
First element number of the copy destination
・If not specified, it's 0.
Label name string indicating the DATA statement you want to read
・Reading starts from the DATA statement that appears first after the label name.
Number of data to be read
・An error occurs if the number of data that can be read is less than the value specified here.
・If not specified, the number of elements in the copy destination array is specified.
DIM DST[5] COPY DST,"@SRC" @SRC DATA 5,1,1,2,4
Copy destination string variable
Copy start position
・If not specified, it's 0.
Copy source string
Copy source start position
・If not specified, it's 0.
Number of characters to copy
・If not specified, the number of characters in the copy source string minus the copy source offset is specified.
COPY A$,"12345"
・Similar to the COPY command, the value between arrays is copied, but even if the number of copy elements at the copy source is larger than the copy destination, the number of elements is not expanded and the data is copied by folding back to the beginning of the array.
・You can specify up to a 2D array for both the copy destination and copy source. When a 2D array is specified, it is handled as a multi-channel ring buffer (or data).
・If a 2D array is specified for both the copy destination and the copy source, the number of channels (number of elements in the first dimension) must be the same.
・When the copy destination is 2D and the copy source is a 1D array, the copy source data is copied to all channels of the copy destination in the same way.
・Operation is not guaranteed if the copy destination and copy source are the same array.
Array treated as a copy destination ring buffer
Copy start position at the copy destination
Copy source array
Copy start position at the copy source
・0, if not specified.
Number of elements to copy
・If not specified, it's the number of elements in the copy source array.
End position of copied data
・When handled as a ring buffer, the returned value is the next copy destination offset.
Position to start sorting in Array1
・0, if not specified.
Number of elements to sort
・If not specified, it's the number of elements in Array1.
An array containing the numbers to sort
Array to be sorted in conjunction with the sorting result of Array1.
・Array 2 to 8 can be omitted.
・Array 2 to 8 can be string arrays.
DIM WORK[10] SORT 0,10,WORK
Sort start position in Array1
・0, if not specified.
Number of elements to sort
・If not specified, it's the number of elements in Array1.
An array containing the numbers to sort
Array to be sorted in conjunction with the sorting result of Array1.
・Array 2 to 8 can be omitted.
・Array 2 to 8 can be string arrays.
DIM WORK[10] RSORT 0,10,WORK
・The number of elements increases by one.
The array to add the element to
The value of the element to add
DIM WORK[10] PUSH WORK,123
・The number of elements reduces by one.
The array whose elements are to be retrieved
The value of the extracted element
DIM WORK[10] PUSH WORK,123 A=POP(WORK)
・The number of elements increases by one.
The array to add the element to
The value of the element to add
DIM WORK[10] UNSHIFT WORK,123
・The number of elements reduces by one.
The array whose elements are to be retrieved
DIM WORK[10] UNSHIFT WORK,123 A=SHIFT(WORK)
・The array type may be an Int, Real or string.
・Partial change is possible by specifying offset and number of elements.
Array to overwrite values
Number or string
The position at which to start writing the value
Number to write
DIM WORK[10] FILL WORK,0
The value whose type is to be examined
Depending on the value type, one of the following numbers is returned:
0 | Default Type | #T_DEFAULT |
1 | Int type | #T_INT |
2 | Real Type | #T_REAL |
3 | String Type | #T_STR |
5 | Int Array | #T_INTARRAY |
6 | Real Array | #T_REALARRAY |
7 | String Array | #T_STRARRAY |
・The default type is a special type that is set when an argument is not specified in a function/command call.
・Use this when you want to create an array other than when defining a variable with VAR.
・ARRAY% creates an Int array, ARRAY# creates a Real array, and ARRAY$ creates a string array.
Array dimensions and number of elements to create
Created array
The array to check
Dimension to check the number of elements: 0 to 3
・If not specified, the number of array dimensions is returned.
・If a dimension is specified, the number of elements in the specified dimension is returned.
・If the dimension is not specified, the number of array dimensions is returned.
DIM WORK[10,20] ? DIM(WORK) ? DIM(WORK,0) ? DIM(WORK,1)
・The numeric value 0 or an empty string is entered in the element of the extended part.
The array to resize
Number of elements after resizing
・You can change only the number of elements written first when defining an array.
・Dimensions cannot be changed.
Array to increase elements
Element insertion position: 0 to the number of array elements
Number of elements to insert: positive number
・1, if not specified.
Insert element value
・If not specified, 0 for numeric arrays and empty string for character arrays.
The array to remove elements from
Element deletion position: 0 to number of array elements -1
Number of elements to delete: positive number
・1, if not specified.
Target array to search
・Multi-dimensional arrays can also be specified.
The value to search for
Found position
・If the value is not found, -1 is returned.
DIM A[]=[1,2,3,4,5] ?FIND(A,3)
Target array to search
・Multi-dimensional arrays can also be specified.
The value to search for
The index of the found position
・The number of returned values must be the same as the number of dimensions of the searched target array.
・If no value is found, -1 is returned for all return values.
DIM A$[3,3]=["1","2","3","4","5","6","7","8","9"] FIND A$, "4" OUT Y,X ?A$[Y,X]
・For type, value, and array, the number of elements and the values of all elements are displayed.
・For strings and string variables, the length of the string is also displayed.
・If the content of the string is too long, the rest is omitted.
・It can be abbreviated as ?? instead of using INSPECT.
INSPECT A ?? "12345"*10