home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 2 / amigaformatcd02.iso / pd / text / alphaspell_suite / varexx / demo / demo.rexx < prev    next >
OS/2 REXX Batch file  |  1996-05-20  |  8KB  |  285 lines

  1. /* Demo Script */
  2.     guifile = 'test.gui'
  3.  
  4.     options results
  5.     launchvarexx = FALSE
  6.  
  7.     /* Open libs needed */
  8.     if ~show("L","rexxsupport.library") then
  9.         if ~addlib("rexxsupport.library", 0, -30) then exit
  10.  
  11.     if ~show("L","rexxreqtools.library") then
  12.         if ~addlib("rexxreqtools.library", 0, -30) then exit
  13.  
  14.     /* Check Varexx is loaded if not load it */
  15.  
  16.     if show( 'p', 'VAREXX' ) ~= 1 then do
  17.         address command 'run varexx'
  18.         waitforport VAREXX
  19.         launchvarexx = TRUE
  20.     end
  21.     address VAREXX
  22.  
  23.     'version'
  24.     if result = '' then result = 0
  25.     if result < 1.7 then do
  26.         call message('This demo needs v1.7 of Varexx or greater.')
  27.         exit
  28.     end
  29.  
  30.     /* Open the port for gui to talk to */
  31.     call openport("WINDOWPORT")
  32.  
  33.     /* Load the gui file into varexx */
  34.     'load 'guifile' WINDOWPORT'
  35.  
  36.     /* Set host to the port for this gui file */
  37.     host = result 
  38.     address value host
  39.  
  40.     /* Display the window */
  41.     show 
  42.     busy set
  43.     call message('Varexx opens Gadtoolsbox Gui files and can set the busy pointer.')
  44.  
  45.     call message('The multiple choice options can be set.')
  46.     setnum one 2
  47.     do n = 1 to 3
  48.         setnum cycle n
  49.         call delay(15)
  50.     end
  51.     setnum cycle 0
  52.  
  53.     call message('The text in cycle gadgets may be changed.')
  54.     setlabel 'label=cycle' 'cycle' 'Well' 'I' 'am' 'very' 'impressed' 'with' 'this' 'all'
  55.     call delay(15)
  56.     do n = 1 to 7
  57.         setnum cycle n
  58.         call delay(15)
  59.     end
  60.     setnum cycle 0
  61.  
  62.  
  63.     call message('The sliders and scrollers can be moved.')
  64.     setnum scroll 10
  65.     setnum slider 10
  66.  
  67.     call message('And their other values altered.')
  68.     setbar scroll min 50 max 150
  69.     setbar slider min 0 max 100
  70.  
  71.     call message('Fixed text and number gadget can be filled.')
  72.     settext text 'Amiga'
  73.     setnum noview 4000
  74.  
  75.     call message('as can the editable ones.')
  76.     settext gad1 'You could change this.'
  77.     setnum num 2001
  78.  
  79.     call message('Checking check boxes.')
  80.     setcheck gad2 check
  81.  
  82.     call message('Add items to listviews.')
  83.     'setlist LIST Haddock Cod Place Skate Herring Tuna'
  84.  
  85.     call message('Opps. You can get rid of them as well')
  86.     'setlist LIST Place del'
  87.  
  88.     call message('and select them.')
  89.     'setlist LIST select Cod'
  90.  
  91.     call message('Clear the list and start again.')
  92.     s.1 = 'Monday'
  93.     s.2 = 'Tuesday'
  94.     s.3 = 'Wednesday'
  95.     s.4 = 'Thursday'
  96.     s.5 = 'Friday'
  97.     s.count = 5
  98.     'setlist LIST clear stem='s
  99.  
  100.     call message('Disable gadgets')
  101.     set slider cycle scroll gad1 gad2 num okay list one file palette disable
  102.  
  103.     call message('and guess what -- Enable them too.')
  104.     set slider cycle scroll gad1 gad2 num okay list one file palette enable
  105.  
  106.     call message('You can change the screen and window titles.')
  107.     setlabel project0 '"' || 'New Window Title' || '"' window
  108.     setlabel project0 '"' || 'New Screen Title' || '"' screen  
  109.  
  110.     call message('You can move windows about.')
  111.     'window x =0 y = 0'
  112.  
  113.     'readcords temp'
  114.  
  115.     fish = 'Click Onwards and play with the GUI and watch the shell' || '0A'x
  116.     fish = fish || 'Try keyboard shortcuts and the rest of the keyboard.' || '0a'x
  117.     fish = fish || ' Click Okay to continue.'
  118.     
  119.     call message( fish )
  120.     'window x ='temp.x 'y = 'temp.y
  121.  
  122.     busy
  123.     do forever
  124.         call waitpkt( "WINDOWPORT" )
  125.  
  126.         packet = getpkt( "WINDOWPORT" )
  127.  
  128.  
  129.         if packet ~= '00000000'x then do 
  130.             class  = getarg(packet)
  131.             type = word( class, 1)
  132.             msg = word( class, 2 )
  133.  
  134.             select
  135.                 when type = closewindow then say 'Clicked on close gadget.'
  136.                 when type = okay     then leave
  137.                 when type = list     then say 'List selected 'msg
  138.                 when type = cycle    then say 'Cycle gadget option 'msg
  139.                 when type = one      then say 'Multiple Choice gadget option 'msg
  140.                 when type = scroll   then say 'Scroller now at 'msg
  141.                 when type = slider   then say 'Slider now at 'msg
  142.                 when type = gad1     then say 'You typed in 'msg
  143.                 when type = num      then say 'Your number is 'msg
  144.                 when type = palette  then say 'Colour #'msg
  145.                 when type = gad2     then say 'Check is 'msg
  146.                 when type = keyboard then do
  147.                     select
  148.                     when msg = down then do
  149.                         'read list number'
  150.                         n = result
  151.                         if n = 'RESULT' then n = 1
  152.                         else 
  153.                             n = n + 1
  154.                         if n > s.count then n = s.count
  155.                         setlist list select s.n
  156.                     end
  157.                     when msg = up then do
  158.                         'read list number'
  159.                         n = result
  160.                         if n = 'RESULT' then n = 2
  161.                         n = n - 1
  162.                         if n < 1 then n = 1
  163.                         setlist list select s.n
  164.                     end
  165.                     otherwise say 'Keyboard 'msg
  166.                     end
  167.                 end
  168.                 when type = gad2    then say 'Check is 'msg
  169.                 when type = file    then do
  170.                     dict = rtfilerequest(, ,'Select a file' , , 'rt_reqpos = reqpos_centerscr')
  171.                     settext gad1 dict
  172.                 end
  173.                 otherwise say class
  174.             end
  175.  
  176.         end
  177.     end
  178.  
  179.     call message( ' Lets us proceed. Try the Zoom Gadget...' )
  180.     window zip
  181.     fish = 'That was Pos zoom. Varexx supports most' || '0a'x
  182.     fish = fish || 'of the options that can be set in GadToolsBox.' || '0a'x
  183.     fish = fish || 'Varexx adapts to fonts and resolutions.'
  184.     call message( fish )
  185.  
  186.     busy set
  187.  
  188.     call message( 'Your arexx script can read from Varexx Gadgets.')
  189.     
  190.     read one
  191.     fish = 'Multiple Choice option = 'result || '0a'x
  192.     read cycle
  193.     fish = fish || 'Cycle gadget option = 'result || '0a'x
  194.     read slider
  195.     fish = fish || 'Slider at 'result || '0a'x
  196.     read scroll
  197.     fish = fish || 'Scroller at 'result 
  198.     call message( fish )
  199.  
  200.     read gad1
  201.     fish = 'You typed : 'result || '0a'x
  202.     read num 
  203.     fish = fish || 'Number entered : 'result || '0a'x
  204.     read palette
  205.     fish = fish || 'Palette colour : 'result || '0a'x
  206.     read gad2
  207.     fish = fish || 'Check is 'result
  208.     call message( fish )
  209.  
  210.     read list
  211.     if result = 'RESULT' then do
  212.         call message( 'No item is selected in the list. But you can...')
  213.     end; else; do
  214.         call message( 'For lists the selected item is 'result' or...')
  215.     end
  216.  
  217.     read list var h 
  218.     fish = 'List all items...' 
  219.     do n = 1 to h.count
  220.         fish = fish || '0a'x || h.n
  221.     end
  222.     drop h
  223.  
  224.     call message( fish )
  225.  
  226.     'hide'
  227.     call message( 'Windows can be hidden')
  228.     'show next'
  229.     call message( 'and if there is more than one in a GUI file.' )
  230.  
  231.     /* Create the context for a new window */
  232.     'spawn WINDOWPORT'
  233.     vhost2 = RESULT
  234.     address value vhost2
  235.  
  236.     /* Change the text of the window */
  237.  
  238.     setlabel okay 'Fish'
  239.     setlabel list 'Fish'
  240.     setlabel 'label=cycle' 'Fish'
  241.     setlabel one 'Fish' 'Fish' 'Fish'
  242.     setlabel scroll 'Fish'
  243.     setlabel slider 'Fish'
  244.     setlabel gad1 'Fish'
  245.     setlabel num 'Fish'
  246.     setlabel palette 'Fish'
  247.     setlabel gad2 'Fish'
  248.     setlabel 'label=text' 'Fish'
  249.     setlabel noview 'Fish'
  250.  
  251.     /* Show the second window */
  252.     'show'
  253.     address
  254.  
  255.     /* Move the other forwards */
  256.     'window front'
  257.  
  258.     call message( 'Both on screen at once !' )
  259.  
  260.     fish = 'And the text in the windows has changed' || '0A'x
  261.     fish = fish || 'useful when used with the locale library.' || '0a'x
  262.     fish = fish || 'if not here....'
  263.     'hide unload'
  264.     address
  265.     call message( fish )
  266.  
  267.     /* Unload and remove both windows */
  268.     'hide unload'
  269.  
  270.     call message('That is all. I Hope you liked it.')
  271.  
  272.     call closeport( "WINDOWPORT" )
  273.  
  274.     if launchvarexx = TRUE then address command vxc
  275.  
  276. exit
  277.  
  278. message : procedure
  279.     call rtezrequest( arg(1),'Onwards','Varexx (Patronizing) Demo','rt_reqpos = reqpos_topleftscr rtez_flags=ezreqf_centertext',)
  280. return
  281.  
  282.  
  283.  
  284.  
  285.