define logical done_init
done_init = exist(mybox_number)
gtvl\gtv SEARCH <POPUP
if (.not.gtv%exist) then
  gtvl\create directory <POPUP /geome 10p 10p
endif
!
! Redefine it each time because of AAAREF symbolics
begin procedure pop_one_box
  let error_status no /new logical
  let mybox_number 0
  if pro%narg.gt.0 then
    if ("&1".eq."^") then
      continue
    else
      on error "let error_status yes"
      let mybox_number &1
    endif
  endif
  if error_status then
    @ plot_one_box 'PopupName' &1
  else
    if (mybox_number.le.0) then
      @ find_window_number 'phy_curs[1]' 'phy_curs[2]' mybox_number
    endif
    @ plot_one_box 'PopupName' 'mybox_number'
  endif
  gtvl\change directory <GREG
end procedure pop_one_box
!
! If possible, re-use existing sub-procedure
if (done_init) then
  if pro%narg.gt.0 then
    @ pop_one_box &1
  else
    greg1\look "@ pop_one_box"
  endif
  return
endif
!
! If first time, create sub-procedure and global Box number
define integer mybox_number /global
!
begin procedure plot_one_box
  !
  gtvl\gtv search <greg<&1&2
  if gtv%exist then
    gtvl\change dir <greg<&1&2
    gtvl\metacode export gag_scratch:&1&2
    gtvl\destroy director <popup
    gtvl\create dir <popup /geome 10p 10p
    gtvl\change dir <popup
    gtvl\metacode import gag_scratch:&1&2
    sic delete gag_scratch:&1&2.meta
    greg1\set expand 'PopupExpand'
    if (popupname.ne."SOURCES") then
      greg1\box
    else
      ! Ideally, one would like to use the SET UNIT GreG mechanism here
      greg1\box /abs
    endif
    gtvl\create window NAME "&1 &2"
    !
  else
    SAY "No such subdir &1 &2"
  endif
  gtvl\change dir <greg
end procedure plot_one_box
!
greg1\look "@ pop_one_box "
!
!
