home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VXREXX.2 / VREDISPO.VRM < prev    next >
Text File  |  1994-12-23  |  5KB  |  217 lines

  1. /* Custom mainline for macro */
  2.  
  3.     signal on SYNTAX name _VRESyntax
  4.     signal _VREMain
  5.  
  6. _VRESyntax:
  7.     parse source . . _VRESourceSpec
  8.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL":" ErrorText(rc), "Error!"
  9.     call VRFini
  10.     exit 32000
  11.  
  12. _VREMain:
  13. /*:VRX         Main
  14. */
  15. /*  Main
  16. */
  17. Main:
  18. /*  Uncomment to debug
  19.     call VRRedirectSTDIO "on"
  20.     trace r
  21. */
  22.     signal on novalue
  23.  
  24. /*  Process the arguments.
  25.     Get the parent window.
  26. */
  27.     parse source . calledAs .
  28.     parent = ""
  29.     argCount = arg()
  30.     argOff = 0
  31.     if( calledAs \= "COMMAND" )then do
  32.         if argCount >= 1 then do
  33.             parent = arg(1)
  34.             argCount = argCount - 1
  35.             argOff = 1
  36.         end
  37.     end
  38.     InitArgs.0 = argCount
  39.     if( argCount > 0 )then do i = 1 to argCount
  40.         InitArgs.i = arg( i + argOff )
  41.     end
  42.     drop calledAs argCount argOff
  43.  
  44. /*  Load the windows
  45. */
  46.     call VRInit
  47.     parse source . . spec
  48.     _VREPrimaryWindowPath = ,
  49.         VRParseFileName( spec, "dpn" ) || ".VRW"
  50.     _VREPrimaryWindow = ,
  51.         VRLoad( parent, _VREPrimaryWindowPath )
  52.     drop parent spec
  53.     if( _VREPrimaryWindow == "" )then do
  54.         call VRMessage "", "Cannot load window:" VRError(), ,
  55.             "Error!"
  56.         _VREReturnValue = 32000
  57.         signal _VRELeaveMain
  58.     end
  59.  
  60. /*  Process events
  61. */
  62.     call Init
  63.     signal on halt
  64.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  65.         _VREEvent = VREvent()
  66.         interpret _VREEvent
  67.     end
  68. _VREHalt:
  69.     _VREReturnValue = Fini()
  70.     call VRDestroy _VREPrimaryWindow
  71. _VRELeaveMain:
  72.     call VRFini
  73. exit _VREReturnValue
  74.  
  75. VRLoadSecondary: procedure
  76.     name = arg( 1 )
  77.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  78.     call VRMethod window, "CenterWindow"
  79.     call VRSet window, "Visible", 1
  80.     call VRMethod window, "Activate"
  81. return window
  82.  
  83. /*:VRX         Fini
  84. */
  85. Fini:
  86.     call VRSet VRWindow(), "Visible", 0
  87. return RetStr
  88.  
  89.  
  90. /*:VRX         Halt
  91. */
  92. Halt:
  93.     signal _VREHalt
  94. return
  95.  
  96.  
  97. /*:VRX         Init
  98. */
  99. /*  
  100.     ret = VREDispO( parent, edit, path, object )
  101.  
  102.     Display the list of properties and method for
  103.     an object for which code can be generated.
  104.  
  105.     Arguments:
  106.         parent          Window parent or ""
  107.         edit            1 if in VRXEdit 
  108.         path            VX-REXX home dir
  109.         object          ID (in VRXEdit) or Class of object
  110.  
  111.     Returns:
  112.         Cancel          ""
  113.         Macro           "MACRO";<macroname>;<parms>
  114. */
  115. Init: procedure expose InitArgs. RetStr VRXEdit VRXPath MacroInfo.
  116.                        
  117.     if( RXFuncQuery( "VRELoadMTLBInfo" ) ) then
  118.         call RXFuncAdd "VRELoadMTLBInfo", "MT", "VRELoadMTInfo"
  119.  
  120.     RetStr = ""
  121.  
  122.     VRXEdit = InitArgs.1
  123.     VRXPath = InitArgs.2
  124.  
  125.     if VRXEdit = 1 then do
  126.     objClass = VRGet( InitArgs.3, "ClassName" )
  127.         objTitle = VRGet( InitArgs.3, "Name" )
  128.     end
  129.     else do
  130.         objClass = InitArgs.3
  131.         objTitle = objClass
  132.     end
  133.  
  134.     window = VRWindow()
  135.     call VRMethod window, "CenterWindow"
  136.     call VRSet window, "Caption",  objTitle || ": Select an action"
  137.     call VRSet window, "Visible", 1
  138.     call VRMethod window, "Activate"
  139.     call VRSet window, "Pointer", "Wait"
  140.  
  141.     fname = GetFileName( objClass )
  142.  
  143.     call VRSet "LB_Operations", "Painting", 0
  144.     call ListMacros fname
  145.     call VRSet "LB_Operations", "Painting", 1
  146.  
  147.     call VRSet "PB_Okay", "Enabled", 1
  148.     call VRSet "PB_Cancel", "Enabled", 1
  149.  
  150.     call VRSet window, "Pointer", "<default>"
  151.  
  152. InitQuit:
  153. return
  154.  
  155.  
  156. /* Get the name of the file listing all the object specific macros
  157. */
  158. GetFileName: procedure expose VRXPath
  159.     parse arg objClass  
  160.     if translate(objClass) = "EDITWINDOW" then do
  161.         objClass = "Window"
  162.     end
  163.     if length( objClass ) > 8 then do
  164.         objClass = left( objClass, 8 )
  165.     end
  166.     fname = VRXPath || "SYSTEM\" || objClass || ".MTO"
  167. return fname
  168.  
  169. /* List all the macros from a file in the list box.
  170. */
  171. ListMacros: procedure expose MacroInfo.
  172.     parse arg fname
  173.     listInfo.0 = 0
  174.     MacroInfo.0 = 0
  175.     call VRELoadMTLBInfo fname, "listInfo.", "MacroInfo."
  176.     call VRMethod "LB_Operations", "AddStringList", "listInfo."
  177. return
  178.  
  179.  
  180. /*:VRX         LB_Operations_DoubleClick
  181. */
  182. LB_Operations_DoubleClick:
  183.     call PB_Okay_Click
  184. return
  185.  
  186.  
  187. /*:VRX         PB_Cancel_Click
  188. */
  189. PB_Cancel_Click:
  190.     call Quit
  191. return
  192.  
  193.  
  194. /*:VRX         PB_Okay_Click
  195. */
  196. PB_Okay_Click: procedure expose RetStr VRXEdit VRXPath MacroInfo.
  197.     item = VRGet( "LB_Operations", "Selected" )
  198.     parse VAR MacroInfo.item  field2 ";" field3
  199.     if field2 \= "" then do
  200.         RetStr = "MACRO" || ";" || field3 || ";" || field2
  201.         call Quit
  202.     end
  203. return
  204.  
  205. /*:VRX         Quit
  206. */
  207. Quit:
  208.     call VRSet VRWindow(), "Shutdown", 1
  209. return
  210.  
  211.  
  212. /*:VRX         Window1_Close
  213. */
  214. Window1_Close:
  215.     call Quit
  216. return
  217.