home *** CD-ROM | disk | FTP | other *** search
/ The Pier Shareware 6 / The_Pier_Shareware_Number_6_(The_Pier_Exchange)_(1995).iso / 035 / vxrxs21a.zip / macros / vxrez / bind.vrm < prev    next >
Text File  |  1994-10-31  |  6KB  |  268 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         AddLine
  88. */
  89. AddLine:
  90.     call VRMethod 'MLE', 'Insert', arg(1) || '0d'x
  91. return
  92.  
  93. /*:VRX         BeginWait
  94. */
  95. BeginWait:
  96.     if( arg(1) \= '' )then call AddLine arg(1)
  97.     call VRSet VRWindow(), 'Pointer', 'Wait'
  98. return
  99.  
  100. /*:VRX         EndWait
  101. */
  102. EndWait:
  103.     call VRSet VRWindow(), 'Pointer', '<Default>'
  104. return
  105.  
  106. /*:VRX         Error
  107. */
  108. Error:
  109.     msg = arg(1) '-- binding aborted!'
  110.  
  111.     call AddLine ''
  112.     call AddLine msg
  113.     call AddLine ''
  114.     call AddLine 'Click on the window or press a key to continue...'
  115.  
  116.     call VRCopyFile EXEName_nrz, EXEName_exe
  117.     window = VRWindow()
  118.  
  119.     call VRSet 'MLE', 'Click', 'call Quit'
  120.     call VRSet window, 'Click', 'call Quit'
  121.     call VRSet window, 'KeyPress', 'call Quit'
  122.  
  123.     call beep 440, 250
  124.     call beep 440, 250
  125. return
  126.  
  127. /*:VRX         Fini
  128. */
  129. Fini:
  130.     window = VRWindow()
  131.     call VRSet window, "Visible", 0
  132.     drop window
  133. return 0
  134.  
  135. /*:VRX         Halt
  136. */
  137. Halt:
  138.     signal _VREHalt
  139. return
  140.  
  141. /*:VRX         Init
  142. */
  143. Init:
  144.     EXEName  = InitArgs.2
  145.     if( EXEName = '' )then do
  146.         call Quit
  147.         return
  148.     end
  149.  
  150.     if( pos( '\', VREProjPermPath() ) = 0 )then do
  151.         call Quit
  152.         return
  153.     end
  154.  
  155.     VXPath   = VREPath()
  156.     ProjPath = VRParseFileName( VREProjPermPath(), "DP" )
  157.     ProjName = VRParseFileName( VREProjPermPath(), "N" )
  158.     RCFile   = ProjPath || "\" || ProjName || ".RC"
  159.     ResFile  = ProjPath || "\" || ProjName || ".RES"
  160.     NewResFile = VXPath || EXEName || ".RES"
  161.  
  162.     if( translate( VXPath ) = translate( ProjPath || '\' ) )then do
  163.         call Quit
  164.         return
  165.     end
  166.  
  167.     EXEName_prj = ProjPath || "\" || EXEName || ".EXE"
  168.     EXEName_exe = VXPath || EXEName || ".EXE"
  169.     EXEName_nrz = VXPath || EXEName || ".NRZ"
  170.  
  171.     if( VRFileExists( EXEName_nrz ) = 0 )then do
  172.         ok = VRCopyFile( EXEName_exe, EXEName_nrz )
  173.         if( ok = 0 ) then do
  174.             call Quit
  175.             return
  176.         end
  177.     end
  178.  
  179.     /* If a *.EXE exists in the project directory,
  180.        use it, otherwise use the *.NRZ in the 
  181.        VX-REXX directory */
  182.  
  183.     if( VRFileExists( EXEName_prj ) \= 0 )then do
  184.         file = EXEName_prj
  185.     end; else do
  186.         file = EXEName_nrz
  187.     end
  188.   
  189.     ok = VRCopyFile( file, EXEName_exe )
  190.     if( ok = 0 )then do
  191.         call Error 'Could not copy' file 'to' EXEName_exe
  192.         return
  193.     end
  194.  
  195.     /* Quit if no .RC file exists in the project
  196.        directory... */
  197.  
  198.     if( VRFileExists( RCFile ) = 0 )then do
  199.         call Quit
  200.         return
  201.     end
  202.  
  203.     call AddLine 'Binding resources for' ProjName
  204.  
  205.     window = VRWindow()
  206.     call VRMethod window, "CenterWindow"
  207.     call VRSet window, "Visible", 1
  208.     call VRMethod window, "Activate"
  209.     drop window
  210.  
  211.     /* Compile up the resources... should really 
  212.        check here that the .RES file's timestamp
  213.        is later than the .RC file's... */
  214.  
  215.     if( VRFileExists( ResFile ) = 0 )then do
  216.         call BeginWait 'Compiling resources...'
  217.         old = directory()
  218.         call directory ProjPath
  219.         address cmd 'rc -r' RCFile '>__out'
  220.         call directory old
  221.         call EndWait
  222.         if( rc \= 0 )then do
  223.             call Error 'Compilation error'
  224.             return
  225.         end
  226.     end
  227.  
  228.     call AddLine 'Copying resource file...'
  229.     ok = VRCopyFile( ResFile, NewResFile )
  230.     if( ok = 0 )then do
  231.         call Error 'Could not copy resource file'
  232.         return
  233.     end
  234.  
  235.     call AddLine 'Binding to executable...'
  236.  
  237.     /* Run the resource compiler to bind to the exe... */
  238.  
  239.     call BeginWait
  240.     old = directory()
  241.     call directory VXPath
  242.     address cmd 'rc' NewResFile EXEName_exe '>__out'
  243.     call VRDeleteFile '__out'
  244.     call directory old   
  245.     call EndWait
  246.  
  247.     if( rc \= 0 )then do
  248.         call Error 'Could not bind to' EXEName_exe
  249.         return
  250.     end 
  251.  
  252.     call Quit
  253. return
  254. /*:VRX         Quit
  255. */
  256. Quit:
  257.     window = VRWindow()
  258.     call VRSet window, "Shutdown", 1
  259.     drop window
  260. return
  261.  
  262. /*:VRX         Window1_Close
  263. */
  264. Window1_Close:
  265.     call Quit
  266. return
  267.  
  268.