ASARR Function
Creates associative array containing specified variables and expressions.
Usage
result = ASARR(key1, value1, ... keyn , valuen)
result = ASARR(keys_arr, values_list)
Input Parameters
keyi—One or more strings, each containing the key name for an element of the associative array.
valuei—Expressions or variables used to set the values of the associative array elements.
keys_arr—A Fstring array containing one or more key names for elements of the associative array.
values_list—A variable of type list containing expressions or variables used to set the values of the associative array elements. The LIST function is used to create list variables.
Returned Value
result—A new associative array containing the specified elements and their associated names.
Keywords
None.
Discussion
An associative array is an array of elements (variables or expressions), each with a unique name. The names act like array subscripts; they let you access the elements of the associative array. An associative array is a distinct data type in PV‑WAVE. You can use a method similar to array subscripting to reference the elements of an associative array.
Example
This example demonstrates how to create an associative array. The INFO and PRINT commands are used to show the contents of the array.
; Create the associative array by specifying the array elements ; (key names and values) as separate parameters. Note that each ; element is of a different data type. asar1 = ASARR('byte', 1B, 'float', 2.2, 'string', '3.3', $ 'struct', {,a:1, b:lindgen(2)}) ; Create an associative array that is equivalent to the previous ; one, only this time the input parameters consist of a string ; array of key names and a list array of values. asar2 = ASARR(['byte', 'float', 'string', 'struct'], $ LIST(1B, 2.2, '3.3', {,a:1, b:lindgen(2)})) ; Show information on the associative array asar1. INFO, asar1, /Full ; ASAR1 AS. ARR = Associative Array(4) ; byte BYTE = 1 ; struct STRUCT = ** Structure $1, 2 tags, 12 length: ; A INT 1 ; B LONG Array(2) ; float FLOAT = 2.20000 ; string STRING = '3.3' ; Print the contents of the associative array asar1. PRINT, asar1 ; {'byte' 1 'struct'{ 1 0 1} 'float' 2.20000 'string'3.3 } ; Print the contents of the associative array asar2. PRINT, asar2 ; {'byte' 1 'struct'{1 0 1} 'float' 2.20000 'string'3.3 }
The contents of the second associative array are the same as the first.