home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VXREXX.3 / SAMPLES / SCAN / SCAN.ERX < prev    next >
Text File  |  1994-12-23  |  5KB  |  210 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 < 2.10 )then do
  8.         call VRMessage "", "This program requires VX-REXX version 2.1 to run.", "Error!"
  9.         return 32000
  10.     end
  11.  
  12.     signal on SYNTAX name _VRESyntax
  13.     signal _VREMain
  14.  
  15. _VRESyntax:
  16.     parse source . . _VRESourceSpec
  17.     call VRMessage "", "Syntax error in" _VRESourceSpec "line" SIGL":" ErrorText(rc), "Error!"
  18.     call VRFini
  19.     exit 32000
  20.  
  21. _VREMain:
  22. /*:VRX         Main
  23. */
  24. /*  Main
  25. */
  26. Main:
  27. /*  Process the arguments.
  28.     Get the parent window.
  29. */
  30.     parse source . calledAs .
  31.     parent = ""
  32.     argCount = arg()
  33.     argOff = 0
  34.     if( calledAs \= "COMMAND" )then do
  35.         if argCount >= 1 then do
  36.             parent = arg(1)
  37.             argCount = argCount - 1
  38.             argOff = 1
  39.         end
  40.     end
  41.     InitArgs.0 = argCount
  42.     if( argCount > 0 )then do i = 1 to argCount
  43.         InitArgs.i = arg( i + argOff )
  44.     end
  45.     drop calledAs argCount argOff
  46.  
  47. /*  Load the windows
  48. */
  49.     call VRInit
  50.     parse source . . spec
  51.     _VREPrimaryWindowPath = ,
  52.         VRParseFileName( spec, "dpn" ) || ".VRW"
  53.     _VREPrimaryWindow = ,
  54.         VRLoad( parent, _VREPrimaryWindowPath )
  55.     drop parent spec
  56.     if( _VREPrimaryWindow == "" )then do
  57.         call VRMessage "", "Cannot load window:" VRError(), ,
  58.             "Error!"
  59.         _VREReturnValue = 32000
  60.         signal _VRELeaveMain
  61.     end
  62.  
  63. /*  Process events
  64. */
  65.     call Init
  66.     signal on halt
  67.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  68.         _VREEvent = VREvent()
  69.         interpret _VREEvent
  70.     end
  71. _VREHalt:
  72.     _VREReturnValue = Fini()
  73.     call VRDestroy _VREPrimaryWindow
  74. _VRELeaveMain:
  75.     call VRFini
  76. exit _VREReturnValue
  77.  
  78. VRLoadSecondary: procedure
  79.     name = arg( 1 )
  80.  
  81.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  82.     call VRMethod window, "CenterWindow"
  83.     call VRSet window, "Visible", 1
  84.     call VRMethod window, "Activate"
  85. return window
  86.  
  87. /*:VRX         Fini
  88. */
  89. Fini: 
  90.     window = VRWindow()
  91.     call VRSet window, "Visible", 0
  92.     if( Label = "" ) then do
  93.         call ETKSetFileField "Line", CurrLine
  94.     end
  95.     else do
  96.         "top"
  97.         "locate /" || Label || ":/"
  98.     end
  99.  
  100.     call VRSet window, "FrameOwner", ""
  101.     call VRSet epmWindow, "Enabled", 1
  102.     drop window
  103.  
  104. return 0
  105.  
  106. /*:VRX         Halt
  107. */
  108. Halt:
  109.     signal _VREHalt
  110. return
  111.  
  112. /*:VRX         Init
  113. */
  114. Init: 
  115.     window = VRWindow()
  116.     if( Address() <> "EPM" ) then do
  117.         call VRMessage window, "You must run this macro from EPM.", "E"
  118.         call Quit
  119.         signal InitDone
  120.     end
  121.  
  122.     /* Set the window owner to the EPM window
  123.     */
  124.     epmWindow = VRMethod( "Screen", "GetActiveWindow" )
  125.     call VRSet window, "FrameOwner", epmWindow
  126.  
  127.     /* Disable the EPM window
  128.     */
  129.     call VRSet epmWindow, "Enabled", 0
  130.  
  131.     call VRMethod window, "CenterWindow"
  132.     call VRSet window, "Visible", 1
  133.     call VRMethod window, "Activate"
  134.  
  135.     "extract /line"
  136.     CurrLine = line.1
  137.     "sayerror Found" ListLabels() "labels"   
  138.     Label = ""
  139.     
  140. InitDone:
  141. return
  142.  
  143. ListLabels: procedure
  144.     "sayerror Locating labels"
  145.     "all /^[abcdefghijklmnopqrstuvwxyz0123456789_]+:/g c"
  146.     if( rc = 0 ) then do
  147.         count = 0
  148.         signal ListDone
  149.     end
  150.  
  151.     "sayerror Extracting labels"
  152.     call VRSet "LB_Labels", "Painting", 0
  153.     "extract /last"
  154.     count = last.1
  155.     "top"
  156.     do i = 1 to count
  157.         "extract /getline"
  158.         parse var getline.1 lineNum name ":" .
  159.         call VRMethod "LB_Labels", "AddString", name
  160.         "+1"
  161.     end
  162.     call VRSet "LB_Labels", "Painting", 1
  163.     "quit"
  164.  
  165. ListDone:
  166. return count
  167.  
  168. /*:VRX         LB_Labels_Click
  169. */
  170. LB_Labels_Click:
  171.     call VRMethod "LB_Labels", "GetSelectedStringList", "list."
  172.     if( list.0 = 1 ) then do
  173.         Label = list.1
  174.     end
  175. return
  176.  
  177. /*:VRX         LB_Labels_DoubleClick
  178. */
  179. LB_Labels_DoubleClick:
  180.     call Quit
  181. return
  182.  
  183. /*:VRX         PB_Cancel_Click
  184. */
  185. PB_Cancel_Click:
  186.     Label = ""
  187.     call Quit
  188. return
  189.  
  190. /*:VRX         PB_OK_Click
  191. */
  192. PB_OK_Click:
  193.     call Quit
  194. return
  195.  
  196. /*:VRX         Quit
  197. */
  198. Quit: 
  199.     window = VRWindow()
  200.     call VRSet window, 'shutdown', 'true'
  201.     drop window
  202. return
  203.  
  204. /*:VRX         Window1_Close
  205. */
  206. Window1_Close:
  207.     call Quit
  208. return
  209.  
  210.