10.3.1 getArrayIndex (gets an index based on the value of array)
Syntax
getArrayIndex [-d element-number] array-name character-string
Description
This command searches for the character string from the array specified for argument and returns the index of the first fully matched array. This command searches for elements from the 0th element in the array sequentially.
Arguments
- -d element-number
-
This command searches for the character string from the two-dimensional array corresponding to the specified element number.
- array-name
-
Specify the name of array from which index is obtained.
- character-string
-
This command specifies the character string to be searched.
Output to the standard output
Character string that indicates index.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
Not less than 1 |
Termination with an error |
Notes
-
If matching character string is not found, the command terminates with an error.
-
A value ranging from 0 to 65535 can be specified for the element-number of argument, but whether the character string can be specified is not verified.
-
Do not specify an array name starting with "adsh" for the array-name argument. If you specify such an array name, it might conflict with the name of another variable used within the part and produce invalid output.
-
The character string that can be specified for array-name is the same as character string that can be used as variable name. However, whether the character string can be specified is not verified.
Examples
set -A input Tokyo Yokohama Fukuoka Nagoya getArrayIndex input Tokyo # "0" is output. getArrayIndex input Yokohama # "1" is output. set -D input { Osaka Fukuoka Nagoya } { Tokyo Yokohama Chiba } getArrayIndex -d 0 input Osaka # "0" is output. getArrayIndex -d 1 input Chiba # "2" is output.