Programmer Guide > Working with Lists and Associative Arrays > How to Reference Nested Lists and Associative Arrays
  

How to Reference Nested Lists and Associative Arrays
Nested lists and associative arrays can be complicated to access. The key is to use parentheses to isolate what you are subscripting. For example:
a = LISTARR(2)
a(0)=0
a(1)=1
b=ASARR()
b('list') = a
; To subscript the list, isolate it using parentheses:
PRINT, (b('list'))(0)
; PV-WAVE prints: 
; 0
; alternatively you could use the following PRINT statement to 
; print the same output
; PRINT, b('list',0)
 
 
; to make matters more complicated append b to the original list
a = [a,b]
; and access the second element of b within that list
PRINT, ((a(2))('list'))(1)
; or alternatively
; PRINT, a(2,'list',1)
 
; in both cases PV-WAVE prints the following:
; 1
 

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.