home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / vxcliser.zip / VXREXX.2 / MACROS / VXREZ / BIND.VRX < prev    next >
Text File  |  1994-12-23  |  6KB  |  247 lines

  1. /*:VRX         Main
  2. */
  3. /*  Main
  4. */
  5. Main:
  6. /*  Process the arguments.
  7.     Get the parent window.
  8. */
  9.     parse source . calledAs .
  10.     parent = ""
  11.     argCount = arg()
  12.     argOff = 0
  13.     if( calledAs \= "COMMAND" )then do
  14.         if argCount >= 1 then do
  15.             parent = arg(1)
  16.             argCount = argCount - 1
  17.             argOff = 1
  18.         end
  19.     end
  20.     InitArgs.0 = argCount
  21.     if( argCount > 0 )then do i = 1 to argCount
  22.         InitArgs.i = arg( i + argOff )
  23.     end
  24.     drop calledAs argCount argOff
  25.  
  26. /*  Load the windows
  27. */
  28.     call VRInit
  29.     parse source . . spec
  30.     _VREPrimaryWindowPath = ,
  31.         VRParseFileName( spec, "dpn" ) || ".VRW"
  32.     _VREPrimaryWindow = ,
  33.         VRLoad( parent, _VREPrimaryWindowPath )
  34.     drop parent spec
  35.     if( _VREPrimaryWindow == "" )then do
  36.         call VRMessage "", "Cannot load window:" VRError(), ,
  37.             "Error!"
  38.         _VREReturnValue = 32000
  39.         signal _VRELeaveMain
  40.     end
  41.  
  42. /*  Process events
  43. */
  44.     call Init
  45.     signal on halt
  46.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  47.         _VREEvent = VREvent()
  48.         interpret _VREEvent
  49.     end
  50. _VREHalt:
  51.     _VREReturnValue = Fini()
  52.     call VRDestroy _VREPrimaryWindow
  53. _VRELeaveMain:
  54.     call VRFini
  55. exit _VREReturnValue
  56.  
  57. VRLoadSecondary: procedure
  58.     name = arg( 1 )
  59.  
  60.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  61.     call VRMethod window, "CenterWindow"
  62.     call VRSet window, "Visible", 1
  63.     call VRMethod window, "Activate"
  64. return window
  65.  
  66. /*:VRX         AddLine
  67. */
  68. AddLine:
  69.     call VRMethod 'MLE', 'Insert', arg(1) || '0d'x
  70. return
  71.  
  72. /*:VRX         BeginWait
  73. */
  74. BeginWait:
  75.     if( arg(1) \= '' )then call AddLine arg(1)
  76.     call VRSet VRWindow(), 'Pointer', 'Wait'
  77. return
  78.  
  79. /*:VRX         EndWait
  80. */
  81. EndWait:
  82.     call VRSet VRWindow(), 'Pointer', '<Default>'
  83. return
  84.  
  85. /*:VRX         Error
  86. */
  87. Error:
  88.     msg = arg(1) '-- binding aborted!'
  89.  
  90.     call AddLine ''
  91.     call AddLine msg
  92.     call AddLine ''
  93.     call AddLine 'Click on the window or press a key to continue...'
  94.  
  95.     call VRCopyFile EXEName_nrz, EXEName_exe
  96.     window = VRWindow()
  97.  
  98.     call VRSet 'MLE', 'Click', 'call Quit'
  99.     call VRSet window, 'Click', 'call Quit'
  100.     call VRSet window, 'KeyPress', 'call Quit'
  101.  
  102.     call beep 440, 250
  103.     call beep 440, 250
  104. return
  105.  
  106. /*:VRX         Fini
  107. */
  108. Fini:
  109.     window = VRWindow()
  110.     call VRSet window, "Visible", 0
  111.     drop window
  112. return 0
  113.  
  114. /*:VRX         Halt
  115. */
  116. Halt:
  117.     signal _VREHalt
  118. return
  119.  
  120. /*:VRX         Init
  121. */
  122. Init:
  123.     EXEName  = InitArgs.2
  124.     if( EXEName = '' )then do
  125.         call Quit
  126.         return
  127.     end
  128.  
  129.     if( pos( '\', VREProjPermPath() ) = 0 )then do
  130.         call Quit
  131.         return
  132.     end
  133.  
  134.     VXPath   = VREPath()
  135.     ProjPath = VRParseFileName( VREProjPermPath(), "DP" )
  136.     ProjName = VRParseFileName( VREProjPermPath(), "N" )
  137.     RCFile   = ProjPath || "\" || ProjName || ".RC"
  138.     ResFile  = ProjPath || "\" || ProjName || ".RES"
  139.     NewResFile = VXPath || EXEName || ".RES"
  140.  
  141.     if( translate( VXPath ) = translate( ProjPath || '\' ) )then do
  142.         call Quit
  143.         return
  144.     end
  145.  
  146.     EXEName_prj = ProjPath || "\" || EXEName || ".EXE"
  147.     EXEName_exe = VXPath || EXEName || ".EXE"
  148.     EXEName_nrz = VXPath || EXEName || ".NRZ"
  149.  
  150.     if( VRFileExists( EXEName_nrz ) = 0 )then do
  151.         ok = VRCopyFile( EXEName_exe, EXEName_nrz )
  152.         if( ok = 0 ) then do
  153.             call Quit
  154.             return
  155.         end
  156.     end
  157.  
  158.     /* If a *.EXE exists in the project directory,
  159.        use it, otherwise use the *.NRZ in the 
  160.        VX-REXX directory */
  161.  
  162.     if( VRFileExists( EXEName_prj ) \= 0 )then do
  163.         file = EXEName_prj
  164.     end; else do
  165.         file = EXEName_nrz
  166.     end
  167.   
  168.     ok = VRCopyFile( file, EXEName_exe )
  169.     if( ok = 0 )then do
  170.         call Error 'Could not copy' file 'to' EXEName_exe
  171.         return
  172.     end
  173.  
  174.     /* Quit if no .RC file exists in the project
  175.        directory... */
  176.  
  177.     if( VRFileExists( RCFile ) = 0 )then do
  178.         call Quit
  179.         return
  180.     end
  181.  
  182.     call AddLine 'Binding resources for' ProjName
  183.  
  184.     window = VRWindow()
  185.     call VRMethod window, "CenterWindow"
  186.     call VRSet window, "Visible", 1
  187.     call VRMethod window, "Activate"
  188.     drop window
  189.  
  190.     /* Compile up the resources... should really 
  191.        check here that the .RES file's timestamp
  192.        is later than the .RC file's... */
  193.  
  194.     if( VRFileExists( ResFile ) = 0 )then do
  195.         call BeginWait 'Compiling resources...'
  196.         old = directory()
  197.         call directory ProjPath
  198.         address cmd 'rc -r' RCFile '>__out'
  199.         call directory old
  200.         call EndWait
  201.         if( rc \= 0 )then do
  202.             call Error 'Compilation error'
  203.             return
  204.         end
  205.     end
  206.  
  207.     call AddLine 'Copying resource file...'
  208.     ok = VRCopyFile( ResFile, NewResFile )
  209.     if( ok = 0 )then do
  210.         call Error 'Could not copy resource file'
  211.         return
  212.     end
  213.  
  214.     call AddLine 'Binding to executable...'
  215.  
  216.     /* Run the resource compiler to bind to the exe... */
  217.  
  218.     call BeginWait
  219.     old = directory()
  220.     call directory VXPath
  221.     address cmd 'rc' NewResFile EXEName_exe '>__out'
  222.     call VRDeleteFile '__out'
  223.     call directory old   
  224.     call EndWait
  225.  
  226.     if( rc \= 0 )then do
  227.         call Error 'Could not bind to' EXEName_exe
  228.         return
  229.     end 
  230.  
  231.     call Quit
  232. return
  233. /*:VRX         Quit
  234. */
  235. Quit:
  236.     window = VRWindow()
  237.     call VRSet window, "Shutdown", 1
  238.     drop window
  239. return
  240.  
  241. /*:VRX         Window1_Close
  242. */
  243. Window1_Close:
  244.     call Quit
  245. return
  246.  
  247.