#! ../../msrexx
/*
 * dy_scl: shows how to use a scrolled list
 *
 * --------------------------------------------------------------
 * |                                                            |
 * | |DISMISS|                                                  |
 * |                                                            |
 * |  +---------------+                  +---------------+      |
 * |  |               |                  |               |      |
 * |  |               |    |TRANSER|     |               |      |
 * |  |               |    |DELETE|      |               |      |
 * |  |               |    |TOP|         |               |      |
 * |  |               |    |REPLACE|     |               |      |
 * |  |               |    |SET|         |               |      |
 * |  |               |    |ADD|         |               |      |
 * |  +---------------+                  +---------------+      |
 * |                                                            |
 * --------------------------------------------------------------
 *
 */
signal on novalue
option mixed setenv

call dy_start()

$dismiss  = dy_button(1, 1,  "DISMISS")

call csh 'ls ~', tab

$handle_scl1 = dy_scl(2, 4, 11, 10, tab, /* tab.0 */, 'm')

$transfer    = dy_button(26, 4,  "TRANFER")
$del         = dy_button(26, 6,  "DELETE")
$top         = dy_button(26, 8,  "TOP")
$rep         = dy_button(26, 10, "REPLACE")
$set         = dy_button(26, 12, "SET")
$add         = dy_button(26, 14, "ADD")

$handle_scl2 = dy_scl(39, 4, 11, 10)

$handle_dy   = dy_end("dy_ex_cb", -25, -10, 67, 20, "n")


call dy_map $handle_dy

say
say '... Returned from dy_map(1)'
say

call dy_map $handle_dy

say
say '... Returned from dy_map(2)'
say

return

dy_ex_cb:procedure

parse arg handle reason

say 'dy_ex_cb: 'reason

select
  when reason = 'F1'  | ,
       reason = 'B'$dismiss then
        {  call dy_unmap(handle)
           call dy_destroy(handle)
           exit 0
        }

  when reason = 'B'$transfer then
    { call do_it
      return 0
    }

  when reason = 'B'$del then
    { call dy_vscl handle, $handle_scl1, num
      if num.0 ~= 0 then call dy_dscl handle, $handle_scl1, num.1, num.0
      return 0
    }

  when reason = 'B'$top then
    { call dy_vscl handle, $handle_scl1, num
      if num.0 ~= 0 then call dy_pscl handle, $handle_scl1, num.1
      return 0
    }

  when reason = 'B'$rep then
    { call dy_vscl handle, $handle_scl1, num
      if num.0 ~= 0 then call dy_rscl handle, $handle_scl1, num.1, "New String"
      return 0
    }

  when reason = 'B'$set then
    { call dy_sscl handle, $handle_scl1, 2, 1
      return 0
    }

  when reason = 'B'$add then
    { strings.1 = 'Last'
      call dy_ascl(handle, $handle_scl1, strings, 1, 0)
      call dy_ascl(handle, $handle_scl2, strings, 1, 0)
      return 0
    }

  when reason = 'focus' then
    { say '.... Focus'
      return 0
    }

  otherwise return 0
end

do_it:procedure expose handle

  say '--------------------------------------------'
  l_num = dy_vscl(handle, $handle_scl1, num)
  do i = 1 to num.0
    say num.i
  end
  say

  l_num = dy_vscl(handle, $handle_scl1, num, strings)
  do i = 1 to num.0
    say num.i strings.i
  end

  call dy_ascl(handle, $handle_scl2, strings, strings.0, 0)

return
