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 / editres.vrm < prev    next >
Text File  |  1994-10-31  |  8KB  |  371 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. /*  Process the arguments.
  19.     Get the parent window.
  20. */
  21.     parse source . calledAs .
  22.     parent = ""
  23.     argCount = arg()
  24.     argOff = 0
  25.     if( calledAs \= "COMMAND" )then do
  26.         if argCount >= 1 then do
  27.             parent = arg(1)
  28.             argCount = argCount - 1
  29.             argOff = 1
  30.         end
  31.     end
  32.     InitArgs.0 = argCount
  33.     if( argCount > 0 )then do i = 1 to argCount
  34.         InitArgs.i = arg( i + argOff )
  35.     end
  36.     drop calledAs argCount argOff
  37.  
  38. /*  Load the windows
  39. */
  40.     call VRInit
  41.     parse source . . spec
  42.  
  43.     if( ProjSaved( parent ) = 0 )then signal _VRELeaveMain
  44.  
  45.     _VREPrimaryWindowPath = ,
  46.         VRParseFileName( spec, "dpn" ) || ".VRW"
  47.     _VREPrimaryWindow = ,
  48.         VRLoad( parent, _VREPrimaryWindowPath )
  49.     drop parent spec
  50.     if( _VREPrimaryWindow == "" )then do
  51.         call VRMessage "", "Cannot load window:" VRError(), ,
  52.             "Error!"
  53.         _VREReturnValue = 32000
  54.         signal _VRELeaveMain
  55.     end
  56.  
  57. /*  Process events
  58. */
  59.     call Init
  60.     signal on halt
  61.     do while( \ VRGet( _VREPrimaryWindow, "Shutdown" ) )
  62.         _VREEvent = VREvent()
  63.         interpret _VREEvent
  64.     end
  65. _VREHalt:
  66.     _VREReturnValue = Fini()
  67.     call VRDestroy _VREPrimaryWindow
  68. _VRELeaveMain:
  69.     call VRFini
  70. exit _VREReturnValue
  71.  
  72. VRLoadSecondary: procedure
  73.     name = arg( 1 )
  74.  
  75.     window = VRLoad( VRWindow(), VRWindowPath(), name )
  76.     call VRMethod window, "CenterWindow"
  77.     call VRSet window, "Visible", 1
  78.     call VRMethod window, "Activate"
  79. return window
  80.  
  81. /*:VRX         AboutMenu_Click
  82. */
  83. AboutMenu_Click:
  84.     path = VREPath() || "MACROS\VXREZ\about.vrm"
  85.     call VRMacro path, VRWindow()
  86. return
  87.  
  88. /*:VRX         BeginWait
  89. */
  90. BeginWait:
  91.     window = VRWindow()
  92.     call VRSet window, 'StatusText', arg(1)
  93.     call VRSet window, 'Pointer', 'Wait'
  94. return
  95.  
  96. /*:VRX         CompileFile
  97. */
  98. CompileFile:
  99.     call BeginWait 'Compiling file...'
  100.     address cmd
  101.     old = directory()
  102.     dir = VRParseFileName( RCPath, 'dp' )
  103.     call directory dir
  104.  
  105.     'rc -r' RCPath '>__out'
  106.  
  107.     call EndWait
  108.  
  109.     if( rc \= 0 )then do
  110.         stem.1 = 'Compilation error:'
  111.         stem.2 = ''
  112.         i = 2
  113.         do while lines( '__out' )
  114.             i = i + 1
  115.             stem.i = linein( '__out' )
  116.         end
  117.         call stream '__out', 'c', 'close'
  118.         stem.0 = i
  119.         call VRMessageStem VRWindow(), 'stem.', 'Edit Resources', 'none'
  120.     end
  121.  
  122.     call VRDeleteFile '__old'
  123.     call directory old
  124. return
  125.  
  126. /*:VRX         CompileMenu_Click
  127. */
  128. CompileMenu_Click:
  129.     call SaveFile
  130.     call CompileFile
  131. return
  132.  
  133. /*:VRX         CopyMenu_Click
  134. */
  135. CopyMenu_Click:
  136.     call VRMethod 'MLE', 'Copy'
  137. return
  138.  
  139. /*:VRX         CutMenu_Click
  140. */
  141. CutMenu_Click:
  142.     call VRMethod 'MLE', 'Cut'
  143. return
  144.  
  145. /*:VRX         DeleteMenu_Click
  146. */
  147. DeleteMenu_Click:
  148.     call VRMethod 'Application', 'PostKeyString', 'MLE', '{Del}'
  149. return
  150.  
  151. /*:VRX         EndWait
  152. */
  153. EndWait:
  154.     window = VRWindow()
  155.     call VRSet window, 'StatusText', arg(1)
  156.     call VRSet window, 'Pointer', '<Default>'
  157. return
  158.  
  159. /*:VRX         Fini
  160. */
  161. Fini:
  162.     window = VRWindow()
  163.     call VRSet window, "Visible", 0
  164.     drop window
  165. return 0
  166.  
  167. /*:VRX         Halt
  168. */
  169. Halt:
  170.     signal _VREHalt
  171. return
  172.  
  173. /*:VRX         IconMenu_Click
  174. */
  175. IconMenu_Click:
  176.     dir = VRParseFileName( RCPath, 'DP' )
  177.     old = directory()
  178.     call directory dir
  179.     'start /f iconedit'
  180.     call directory old
  181. return
  182.  
  183. /*:VRX         ImportFile
  184. */
  185. ImportFile:
  186.     if( arg() = 0 )then do
  187.         path = VRParseFileName( RCPath, "DP" ) || '\*.*'
  188.         do while( path \= '' )
  189.             path = VRFileDialog( VRWindow(), 'Import file', 'o', path )
  190.             if( path \= '' & VRFileExists( path ) = 1 )then leave
  191.         end
  192.     end; else do
  193.         path = arg( 1 )
  194.     end
  195.     if( path = '' )then return
  196.     
  197.     event = VRGet( 'MLE', 'Change' )
  198.     call VRSet 'MLE', 'Change', ''
  199.  
  200.     call BeginWait "Loading file..."
  201.  
  202.     value = charin( path, 1, chars( path ) )
  203.     if( length( value ) > 0 )then do
  204.         call VRMethod 'MLE', 'Insert', value
  205.     end
  206.     call stream path, 'c', 'close'
  207.  
  208.     call EndWait
  209.  
  210.     call VRSet 'MLE', 'Change', event
  211.     MLEChanged = 1
  212. return
  213.  
  214. /*:VRX         ImportMenu_Click
  215. */
  216. ImportMenu_Click:
  217.     call ImportFile
  218. return
  219.  
  220. /*:VRX         Init
  221. */
  222. Init:
  223.     RCPath = VRParseFileName( ProjectPath, "DPN" ) || '.RC'
  224.     MLEChanged = 0
  225.  
  226.     window = VRWindow()
  227.  
  228. /*
  229.     call VRSet window, 'Caption', 'Editing RC File' VRParseFileName( RCPath, "NE" )
  230. */
  231.  
  232.     call VRSet 'MLE', 'Value', ''
  233.     call ImportFile RCPath
  234.     MLEChanged = 0
  235.  
  236.     call VRMethod window, "CenterWindow"
  237.     call VRSet window, "Visible", 1
  238.     call VRMethod window, "Activate"
  239.     drop window
  240. return
  241.  
  242. /*:VRX         InsertResource
  243. */
  244. InsertResource: 
  245.     path = VREPath() || "MACROS\VXREZ\resource.vrm"
  246.     call VRMacro path, VRWindow(), arg(1)
  247.     insert = result
  248.     if( insert \= '' )then do
  249.         call VRMethod 'MLE', 'Insert', insert || '0d'x
  250.     end
  251. return
  252.  
  253. /*:VRX         MLE_Change
  254. */
  255. MLE_Change:
  256.     MLEChanged = 1
  257. return
  258.  
  259. /*:VRX         MLE_ContextMenu
  260. */
  261. MLE_ContextMenu:
  262.     call VRMethod 'EditMenu', 'Popup'
  263. return
  264.  
  265. /*:VRX         OS2Menu_Click
  266. */
  267. OS2Menu_Click:
  268.     dir = VRParseFileName( RCPath, 'PD' )
  269.     old = directory()
  270.     call directory dir
  271.     'start /k /f'
  272.     call directory old
  273. return
  274.  
  275. /*:VRX         PasteMenu_Click
  276. */
  277. PasteMenu_Click:
  278.     call VRMethod 'MLE', 'Paste'
  279. return
  280.  
  281. /*:VRX         ProjSaved
  282. */
  283. ProjSaved:
  284.     parse arg parent
  285.     ok = 1
  286.     ProjectPath = VREProjPermPath()
  287.     if( pos( '\', ProjectPath ) = 0 )then do
  288.         msg = 'Please save the project to disk before editing any resources.'
  289.         call VRMessage parent, msg, 'Edit Resources'
  290.         ok = 0
  291.     end
  292. return ok
  293.  
  294. /*:VRX         Quit
  295. */
  296. Quit:
  297.     window = VRWindow()
  298.     call VRSet window, "Shutdown", 1
  299.     drop window
  300. return
  301.  
  302. /*:VRX         ResourceMenu_Click
  303. */
  304. ResourceMenu_Click:
  305.     call InsertResource
  306. return
  307.  
  308. /*:VRX         SaveFile
  309. */
  310. SaveFile:
  311.     call BeginWait 'Saving file...'
  312.     call VRDeleteFile RCPath
  313.     value = VRGet( 'MLE', 'Value' )
  314.     if( length( value ) \= 0 )then do
  315.         last = right( value, 1 )
  316.         if( last \= '0a'x & last \= '0d'x )then do
  317.             value = value || '0d'x
  318.         end
  319.     end
  320.     call charout RCPath, value, 1
  321.     call stream RCPath, 'c', 'close'
  322.     MLEChanged = 0
  323.     call EndWait
  324. return
  325.  
  326. /*:VRX         SaveMenu_Click
  327. */
  328. SaveMenu_Click:
  329.     call SaveFile
  330. return
  331.  
  332. /*:VRX         UndoMenu_Click
  333. */
  334. UndoMenu_Click:
  335.     call VRMethod 'MLE', 'Undo'
  336. return
  337.  
  338. /*:VRX         Window1_Close
  339. */
  340. Window1_Close:
  341.     if( MLEChanged = 1 )then do
  342.         buttons.0 = 3
  343.         buttons.1 = '~Save'
  344.         buttons.2 = '~Discard'
  345.         buttons.3 = '~Cancel'
  346.         default   = 1
  347.         esc       = 3
  348.         msg = 'File has changed.  Do you wish to save it before quitting?'
  349.         response  = VRMessage( VRWindow(), msg, ,
  350.                                'Edit Resources', 'q', ,
  351.                                'buttons.', default, esc )
  352.         if( response = 3 )then return
  353.         if( response = 1 )then call SaveFile        
  354.     end
  355.     call Quit
  356. return
  357.  
  358. /*:VRX         Window1_DragDrop
  359. */
  360. Window1_DragDrop: 
  361.     file = VRInfo( "SourceFile" )
  362.     call InsertResource file
  363. return
  364.  
  365. /*:VRX         Window1_Help
  366. */
  367. Window1_Help: 
  368.     address cmd 'view progguid.inf Adding resources to your project'
  369. return
  370.  
  371.