home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / SYSTEM.$$$ / RXCONS.VRM < prev    next >
Text File  |  1993-09-01  |  5KB  |  196 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         Comments
  89. */
  90. Comments:
  91. /*  
  92.     RXCons: Generate a prototype for the REXX constructs
  93.  
  94.     Usage:  call RXCons <Parent>
  95.  
  96.     Where:  Parent is the parent window for the dialog
  97. */
  98. return
  99.  
  100. /*:VRX         Error
  101. */
  102. Error: procedure
  103.     field = arg( 1 )
  104.     error = arg( 2 )
  105.     call VRMessage VRWindow(), error, "Error"
  106.     call VRMethod field, "SetFocus"
  107. return
  108.  
  109. /*:VRX         Fini
  110. */
  111. Fini:
  112.     window = VRWindow()
  113.     call VRSet window, "Visible", 0
  114.     drop window
  115. return Prototype
  116.  
  117. /*:VRX         Halt
  118. */
  119. Halt:
  120.     signal _VREHalt
  121. return
  122.  
  123. /*:VRX         Init
  124. */
  125. Init:
  126.  
  127.     Prototype = ""
  128.  
  129. /*  Only one argument is accepted, which identifies what kind of REXX 
  130.     construct it is. The argument is a string, e.g. "IF-THEN-ELSE".  
  131. */
  132.     cons_name = InitArgs.2
  133.  
  134.     select 
  135.        when cons_name == "if-then" then
  136.           Prototype = "if a = b then do" || "0d0a"x || "end" || "0d0a"x
  137.        when cons_name == "if-then-else" then 
  138.           Prototype = "if a = b then do" || "0d0a"x || "end" || "0d0a"x ||,
  139.                       "else do" || "0d0a"x || "end" || "0d0a"x
  140.        when cons_name == "simple-do" then 
  141.           Prototype = "do" || "0d0a"x || "end" || "0d0a"x
  142.        when cons_name == "do-while" then 
  143.           Prototype = "do while a = b" || "0d0a"x || "end" || "0d0a"x
  144.        when cons_name == "do-until" then 
  145.           Prototype = "do until a = b" || "0d0a"x || "end" || "0d0a"x
  146.        when cons_name == "simple-iterative-loop" then 
  147.           Prototype = "do 100" || "0d0a"x || "end" || "0d0a"x
  148.        when cons_name == "unconditional-iterative-loop" then 
  149.           Prototype = "do index = 1 to 100" || "0d0a"x || "end" || "0d0a"x
  150.        when cons_name == "conditional-iterative-loop-with-by-for" then 
  151.           Prototype = "do index = 1 to 100 by 1 for 100" || "0d0a"x ||,
  152.                       "end" || "0d0a"x
  153.        when cons_name == "conditional-iterative-loop-with-while" then 
  154.           Prototype = "do index = 1 to 100 while a = b" || "0d0a"x ||,
  155.                       "end" || "0d0a"x
  156.        when cons_name == "conditional-iterative-loop-with-until" then 
  157.           Prototype = "do index = 1 to 100 until a = b" || "0d0a"x ||,
  158.                       "end" || "0d0a"x
  159.        when cons_name == "do-forever-leave" then 
  160.           Prototype = "do forever" || "0d0a"x || "    if a = b then leave" ||,
  161.                       "0d0a"x || "end" || "0d0a"x
  162.        when cons_name == "select-when" then 
  163.           Prototype = "select" || "0d0a"x ||,
  164.                       "    when a = b then do" || "0d0a"x ||,
  165.                       "    end" || "0d0a"x ||,
  166.                       "    when b = c then do" || "0d0a"x ||,
  167.                       "    end" || "0d0a"x ||, 
  168.                       "    when c = d then do" || "0d0a"x ||,
  169.                       "    end" || "0d0a"x ||,
  170.                       "    otherwise do" || "0d0a"x ||,
  171.                       "    end" || "0d0a"x,
  172.                       "end" || "0d0a"x
  173.        otherwise
  174.           nop
  175.     end
  176.  
  177.     call Quit
  178.  
  179. return
  180.  
  181. /*:VRX         Quit
  182. */
  183. Quit:
  184.     window = VRWindow()
  185.     call VRSet window, "Shutdown", 1
  186.     drop window
  187. return
  188.  
  189. /*:VRX         Window1_Close
  190. */
  191. Window1_Close:
  192.     rc = ""
  193.     call Quit
  194. return
  195.  
  196.