home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxdemo.zip / MACROS.$$$ / OBJLIST.VRM < prev    next >
Text File  |  1993-09-03  |  5KB  |  207 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         DisplayNotebooks
  89. */
  90. DisplayNotebooks: procedure expose InitArgs.
  91.  
  92. /*
  93. call vrredirectstdio
  94. trace r
  95. */
  96.     ok = VRMethod( "ObjectList", "GetSelectedStringList", "selectedList." )
  97.     do i = 1 to selectedList.0
  98.         parse VAR selectedList.i . ';' hnd                
  99.         call VRMethod InitArgs.2, "NotebookOpen", hnd
  100.     end
  101.     call Quit
  102.  
  103. return
  104.  
  105. /*:VRX         Fini
  106. */
  107. Fini:
  108.     window = VRWindow()
  109.     call VRSet window, "Visible", 0
  110.     drop window
  111. return 0
  112.  
  113. /*:VRX         Halt
  114. */
  115. Halt:
  116.     signal _VREHalt
  117. return
  118.  
  119. /*:VRX         Init
  120. */
  121.  
  122. Init: procedure expose nameList. hndList. InitArgs.  
  123.  
  124. /*  Assume invoked as a VRXEDIT macro so
  125.         InitArgs.0 = 2
  126.         InitArgs.1 = <object>
  127.         InitArgs.2 = <editWindow>
  128. */
  129.     window = VRWindow()
  130.     call VRMethod window, "CenterWindow"
  131.  
  132. /*  Fill list with names of objects in hndList.
  133. */ 
  134.     call VRMethod InitArgs.2, "ListChildren", "hndList." 
  135.     nameList.0 = hndList.0
  136.     do i = 1 to hndList.0
  137.         nameList.i = Left( VRGet(hndList.i, "Name"), 30 ) || ';' || hndList.i
  138.     end
  139.  
  140. /* Display the List of Objects
  141. */
  142.     ok = VRMethod( "ObjectList", "AddStringList", "nameList.", )
  143.     ok = VRSet( "ObjectList", "Selected", 1 )
  144.  
  145.     objname = VRGet( InitArgs.2, "Name" )
  146.     call VRSet window, "Caption", "Object list for" objname
  147.  
  148.     call VRSet window, "Visible", 1
  149.     call VRMethod window, "Activate"
  150.  
  151.     return
  152.  
  153.  
  154. /*:VRX         ObjectList_DoubleClick
  155. */
  156. ObjectList_DoubleClick:
  157.     call DisplayNotebooks
  158. return
  159.  
  160. /*:VRX         OpenNotebook_Click
  161. */
  162. OpenNotebook_Click:
  163.     call DisplayNotebooks
  164. return
  165.  
  166. /*:VRX         Quit
  167. */
  168. Quit:
  169.     window = VRWindow()
  170.     call VRSet window, "Shutdown", 1
  171.     drop window
  172. return
  173.  
  174. /*:VRX         Window1_Close
  175. */
  176. Window1_Close:
  177.     call Quit
  178. return
  179.  
  180. /*:VRX         Window1_Resize
  181. */
  182. Window1_Resize:
  183. /*
  184.     ok = VRSet( "Window1", "Painting", 0 )
  185.  
  186.     top = VRGet( "ObjectList", "Top" )
  187.     left = VRGet( "ObjectList", "Left" )
  188.  
  189.  
  190.     height = VRGet( "Window1", "InteriorHeight" ) ,
  191.         - VRGet( "OpenNotebook", "Height" )
  192.     width = VRGet( "Window1", "InteriorWidth" )
  193.  
  194.     ok = VRSet( "OpenNotebook", ,
  195.         "Top", height - top, ,
  196.     )
  197.  
  198.     ok = VRSet( "ObjectList", ,
  199.         "Height", height - 3 * top, ,
  200.         "Width", width - 3 * left, ,
  201.     )
  202.  
  203.     ok = VRSet( "Window1", "Painting", 1 )
  204. */
  205. return
  206.  
  207.