#!/usr/local/bin/wermit

; Local array testing script.

; Declare top-level array A.  There is no top-level B.

dcl \&a[] = a0-one a0-two a0-three

def x1 {
  local \&a[] \&b[]  ; Local A and B at level 1
  dcl \&a[] = a1-one a1-two a1-three
  dcl \&b[] = b1-one b1-two b1-three
  echo ENTERING LEVEL 1 WITH LOCAL A AND B ARRAYS...
  echo You should see "a1-one" thru "a1-three" for A
  echo and "b1-one" thru "b1-three" for B:
  show array a
  show array b
  x2
  echo BACK AT LEVEL 1
  echo You should see "a1-one" thru "a1-three" for A
  echo and "b1-one" thru "b1-three" for B:
  show array a
  show array b
}
def x2 {
  local \&b[]        ; Local B but not A at level 2
  dcl \&b[] = b2-one b2-two b2-three
  echo ENTERING LEVEL 2 WITH LOCAL B BUT NOT A...
  echo You should see "a1-one" thru "a1-three" for A
  echo and "b2-one" thru "b2-three" for B:
  show array a
  show array b
  x3
  echo BACK AT LEVEL 2
  echo You should see "a1-one" thru "a1-three" for A
  echo and "b2-one" thru "b2-three" for B:
  show array a
  show array b
}
def x3 {
  local \&a[]
  dcl \&a[] = a3-one a3-two a3-three a3-four
  echo ENTERING LEVEL 3 WITH LOCAL A BUT NOT B...
  echo You should see "a3-one" thru "a3-three" for A
  echo and "b2-one" thru "b2-three" for B:
  show array a
  show array b
}

echo TOP LEVEL
echo You should see "a0-one" thru "a0-three" for A and B not declared:
show array a
show array b
x1
echo BACK AT TOP LEVEL
echo You should see "a0-one" thru "a0-three" for A and B not declared:
show array a
show array b

