ASKEYS Function

Obtains the key names for a given associative array.

Usage

    result = ASKEYS(asarr)

Input Parameters

asarr—The name of an associative array.

Returned Value

result—A string containing the key names in the given associative array. If the array is empty, an empty string is returned.

Keywords

None.

Discussion

A key name is the name associated with an element in an associative array. ASKEYS returns the key names of the elements in an associative array. If the associative array is empty, an empty string is returned. To create an associative array, use the ASARR function.

Example

ASKEYS is used to obtain the key names in an associative array. The names are used to reference the values of the array to replace the original values with new integer values. The INFO command is then used to show the modified contents of the associative array.

asar = ASARR('byte', 1B, 'float', 2.2, 'string', '3.3', $
   'struct', {,a:1, b:lindgen(2)})
keys = ASKEYS(asar)
PRINT, keys
; PV-WAVE prints: byte struct float string
; These key names appear later in the output of the INFO command.
FOR I=0L, N_ELEMENTS(asar1) - 1 DO $
   asar1(keys(i)) = i + 10

; Show the replaced values.
INFO, asar1, /Full
; ASAR1 AS. ARR = Associative Array(4) 
;    byte  INT  =  10
;    struct  INT  =  11
;    float  INT  =  12
;    string  INT  =  13