home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / SYSTEM.$$$ / STREAM.VRM < prev    next >
Text File  |  1993-09-01  |  7KB  |  290 lines

  1. /* Custom mainline for macro */
  2.  
  3.     call RXFuncAdd "VRLoadFuncs", "VROBJ", "VRLoadFuncs"
  4.     call VRLoadFuncs
  5.  
  6.     _VREVersion = SubWord( VRVersion( "VRObj" ), 1, 1 )
  7.     if( _VREVersion < 1.01 )then do
  8.         call VRMessage "", "This program requires VX-REXX version 1.01 to run", "Error!"
  9.         _VREReturnValue = 32000
  10.         signal _VRELeaveMain
  11.     end
  12.  
  13.     signal on SYNTAX name _VRESyntax
  14.     signal _VREMain
  15.  
  16. _VRESyntax:
  17.     parse source . . _VRESourceSpec
  18.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL, "Error!"
  19.     _VREReturnValue = 32000
  20.     signal _VRELeaveMain
  21.  
  22. _VREMain:
  23. /*:VRX         Main
  24. */
  25. /*  Main
  26. */
  27. Main:
  28. /*  Process the arguments.
  29.     Get the parent window.
  30. */
  31.     parse source . calledAs .
  32.     parent = ""
  33.     argCount = arg()
  34.     argOff = 0
  35.     if( calledAs \= "COMMAND" )then do
  36.         if argCount >= 1 then do
  37.             parent = arg(1)
  38.             argCount = argCount - 1
  39.             argOff = 1
  40.         end
  41.     end
  42.     InitArgs.0 = argCount
  43.     if( argCount > 0 )then do i = 1 to argCount
  44.         InitArgs.i = arg( i + argOff )
  45.     end
  46.     drop calledAs argCount argOff
  47.  
  48. /*  Load the windows
  49. */
  50.     call VRInit
  51.     parse source . . spec
  52.     _VREPrimaryWindowPath = ,
  53.         VRParseFileName( spec, "dpn" ) || ".VRW"
  54.     _VREPrimaryWindow = ,
  55.         VRLoad( parent, _VREPrimaryWindowPath )
  56.     drop parent spec
  57.     if( _VREPrimaryWindow == "" )then do
  58.         call VRMessage "", "Cannot load window:" VRError(), ,
  59.             "Error!"
  60.         _VREReturnValue = 32000
  61.         signal _VRELeaveMain
  62.     end
  63.  
  64. /*  Process events
  65. */
  66.     call Init
  67.     signal on halt
  68.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  69.         _VREEvent = VREvent()
  70.         interpret _VREEvent
  71.     end
  72. _VREHalt:
  73.     _VREReturnValue = Fini()
  74.     call VRDestroy _VREPrimaryWindow
  75. _VRELeaveMain:
  76.     call VRFini
  77. exit _VREReturnValue
  78.  
  79. VRLoadSecondary: procedure
  80.     name = arg( 1 )
  81.  
  82.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  83.     call VRMethod window, "CenterWindow"
  84.     call VRSet window, "Visible", 1
  85.     call VRMethod window, "Activate"
  86. return window
  87.  
  88. /*:VRX         cmd_ef_Change
  89. */
  90. cmd_ef_Change:
  91.    if VRGet( "cmd_ef", "value" ) == "Seek" then do
  92.       call VRSet "seek_gb", "enabled", 1
  93.       call VRSet "offset_ef", "enabled", 1
  94.       call VRSet "offset_dt", "enabled", 1
  95.       call VRSet "offset_cb", "enabled", 1
  96.       call VRSet "beg_rb", "enabled", 1
  97.       call VRSet "end_rb", "enabled", 1
  98.       call VRSet "for_rb", "enabled", 1
  99.       call VRSet "bak_rb", "enabled", 1
  100.    end
  101.    else do
  102.       call VRSet "seek_gb", "enabled", 0
  103.       call VRSet "offset_ef", "enabled", 0
  104.       call VRSet "offset_dt", "enabled", 0
  105.       call VRSet "offset_cb", "enabled", 0
  106.       call VRSet "beg_rb", "enabled", 0
  107.       call VRSet "end_rb", "enabled", 0
  108.       call VRSet "for_rb", "enabled", 0
  109.       call VRSet "bak_rb", "enabled", 0
  110.    end
  111. return
  112.  
  113. /*:VRX         cmd_rb_Click
  114. */
  115. cmd_rb_Click:
  116.    call VRSet "cmd_dt", "enabled", 1
  117.    call VRSet "cmd_ef", "enabled", 1
  118.    call cmd_ef_Change
  119. return
  120.  
  121. /*:VRX         Comments
  122. */
  123. Comments:
  124. /*  
  125.     STREAM: Generate a prototype the REXX function STREAM
  126.  
  127.     Usage:  call Stream <Parent>
  128.  
  129.     Where:  Parent is the parent window for the dialog
  130.  
  131. */
  132. return
  133.  
  134. /*:VRX         desc_rb_Click
  135. */
  136. desc_rb_Click:
  137.    call VRSet "cmd_dt", "enabled", 0
  138.    call VRSet "cmd_ef", "enabled", 0
  139.    call VRSet "seek_gb", "enabled", 0
  140.    call VRSet "offset_ef", "enabled", 0
  141.    call VRSet "offset_dt", "enabled", 0
  142.    call VRSet "offset_cb", "enabled", 0
  143.    call VRSet "beg_rb", "enabled", 0
  144.    call VRSet "end_rb", "enabled", 0
  145.    call VRSet "for_rb", "enabled", 0
  146.    call VRSet "bak_rb", "enabled", 0
  147. return
  148.  
  149. /*:VRX         Error
  150. */
  151. Error: procedure
  152.     field = arg( 1 )
  153.     error = arg( 2 )
  154.     call VRMessage VRWindow(), error, "Error"
  155.     call VRMethod field, "SetFocus"
  156. return
  157. /*:VRX         Fini
  158. */
  159. Fini:
  160.     window = VRWindow()
  161.     call VRSet window, "Visible", 0
  162.     drop window
  163. return Prototype
  164.  
  165. /*:VRX         Halt
  166. */
  167. Halt:
  168.     signal _VREHalt
  169. return
  170.  
  171. /*:VRX         Init
  172. */
  173. Init:
  174.  
  175.     Prototype = ""
  176.  
  177.     window = VRWindow()
  178.     call VRMethod window, "CenterWindow"
  179.     call VRSet window, "Visible", 1
  180.     call VRMethod window, "Activate"
  181.     drop window
  182.  
  183. return
  184.  
  185. /*:VRX         PB_1_Click
  186. */
  187. PB_1_Click:
  188.     stream_name = VRGet( "name_ef", "value" )
  189.     if stream_name == "" then do
  190.        call VRMessage VRWindow(), "You must specify a stream name!"
  191.        return
  192.     end
  193.     else do
  194.        if VRGet( "quo_cb", "set" ) == 1 then 
  195.           stream_name = '"' || stream_name || '"'
  196.     end
  197.  
  198.     if VRGet( "cmd_rb", "set" ) == 1 then do
  199.        operation = "Command"
  200.        stream_command = VRGet( "cmd_ef", "value" ) 
  201.        if stream_command == "" then do
  202.           call VRMessage VRWindow(), "You must specify a stream command when using Command option!"
  203.           return
  204.        end
  205.        else do
  206.           cmd_type = word( stream_command, 1 )
  207.           if cmd_type == "Seek" then do
  208.              offset = VRGet( "offset_ef", "value" ) 
  209.              if offset == "" then do
  210.                 call VRMessage VRWindow(), "You must specify an offset for the Seek command!"
  211.                 return
  212.              end
  213.              else do
  214.                 if VRGet( "beg_rb", "set" ) == 1 then
  215.                    sym = "="
  216.                 else if VRGet( "end_rb", "set" ) == 1 then
  217.                         sym = "<"
  218.                      else if VRGet( "for_rb", "set" ) == 1 then
  219.                              sym = "+"
  220.                           else
  221.                              sym = "-"
  222.             
  223.                 if datatype( offset ) \== "NUM" then
  224.                    stream_command = '"Seek ' || sym || '"' || offset
  225.                 else
  226.                    stream_command = '"Seek ' || sym || offset || '"'
  227.              end
  228.           end
  229.           else do
  230.              stream_command = '"' || stream_command || '"'
  231.           end
  232.        end 
  233.        Prototype = "strm_status = Stream( "stream_name', "'operation'", 'stream_command' )'
  234.     end
  235.     else do
  236.        if VRGet( "desc_rb", "set" ) == 1 then
  237.           operation = "Description" 
  238.        else 
  239.           operation = "State"
  240.        Prototype = "strm_status = Stream( "stream_name', "'operation'" )'
  241.     end
  242.  
  243.     call Quit
  244.  
  245. return
  246.  
  247. /*:VRX         PB_2_Click
  248. */
  249. PB_2_Click:
  250.     rc = ""
  251.     call Quit
  252. return
  253.  
  254. /*:VRX         PB_3_Click
  255. */
  256. PB_3_Click:
  257.     "view rexx.inf Stream"
  258. return
  259.  
  260. /*:VRX         Quit
  261. */
  262. Quit:
  263.     window = VRWindow()
  264.     call VRSet window, "Shutdown", 1
  265.     drop window
  266. return
  267.  
  268. /*:VRX         state_rb_Click
  269. */
  270. state_rb_Click:
  271.    call VRSet "cmd_dt", "enabled", 0
  272.    call VRSet "cmd_ef", "enabled", 0
  273.    call VRSet "seek_gb", "enabled", 0
  274.    call VRSet "offset_ef", "enabled", 0
  275.    call VRSet "offset_dt", "enabled", 0
  276.    call VRSet "offset_cb", "enabled", 0
  277.    call VRSet "beg_rb", "enabled", 0
  278.    call VRSet "end_rb", "enabled", 0
  279.    call VRSet "for_rb", "enabled", 0
  280.    call VRSet "bak_rb", "enabled", 0
  281. return
  282.  
  283. /*:VRX         Window1_Close
  284. */
  285. Window1_Close:
  286.     rc = ""
  287.     call Quit
  288. return
  289.  
  290.