$SETARRAYBYKEY (set value to array with key)
$SETARRAYBYKEY adds keyed information to an array.
Syntax
$SETARRAYBYKEY(array-name,key-value,character-string)
Values
-
array-name
Specifies the variable name of the array variable into to which a value is to be added.
-
key-value
Specifies the key of the value that is to be added to the array variable.
-
character-string
Specifies the value to be added to the array variable, either as a constant or a variable. A constant must be enclosed in single quotation marks ('').
Status
The following table lists and describes the possible statuses:
Status |
Description |
---|---|
NORMAL |
Normal end |
NODATA |
— |
ERROR |
— |
Script execution interrupted |
An invalid argument was specified, or an error other than the above occurred. |
Example
The following example updates the value of array number 1 in the key MEM from 128 to 1024, and acquires the updated value by specifying its key:
[SET_VALUE] $CLEARARRAY(ARY) $SETARRAYBYKEY(ARY,'CPU','100') # ARY[1] CPU[1] $SETARRAYBYKEY(ARY,'CPU','200') # ARY[2] CPU[2] $SETARRAYBYKEY(ARY,'HD' ,'40') # ARY[3] HD[1] $SETARRAYBYKEY(ARY,'HD' ,'20') # ARY[4] HD[2] $SETARRAYBYKEY(ARY,'MEM','128') # ARY[5] MEM[1] $SETARRAYBYKEY(ARY,'MEM','256') # ARY[6] MEM[2] $UPDARRAYBYKEY(ARY,'MEM',1,'1024') VAL = $GETARRAYBYKEY(ARY,'MEM',1) MSG = 'ARY MEM[1] = '+VAL $ECHO(MSG)
- Execution result:
-
ARY MEM[1] = 1024