home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / pcqpascalv1.2d.lha / Scripts / CED-ShowError < prev    next >
Encoding:
Text File  |  1991-09-01  |  3.0 KB  |  132 lines

  1. /*
  2.  
  3. CED-ShowError
  4.  
  5. This Arexx program displays the errors generated by the PCQ Pascal
  6. compiler, using the CygnusEd Professional text editor.  It should
  7. be called as follows:
  8.  
  9.     CED-ShowError SourceFile OutputFile ErrorFile
  10.  
  11. CED-ShowErrors reads the errorfile, which must have been generated
  12. by PCQ Pascal in "quiet" mode.  It displays the first error in the
  13. appropriate source file (not necessarily the SourceFile), then
  14. erases the OutputFile and ErrorFile.
  15.  
  16. This file was designed to be an error handler for the PCQ make
  17. utility.  It might work for other purposes, but I'd be careful if
  18. I were you.
  19.  
  20. To use this file with PCQ, you'll need to include the following
  21. line in your configuration file:
  22.  
  23.     CompilerError rx CED-ShowError \s \d \e
  24.  
  25. You will also, of course, need CygnusEd Professional and Arexx,
  26. both of which are commercial products.
  27.  
  28. */
  29.  
  30. /* Read the command line parameters */
  31.  
  32. parse arg SourceFileName OutputFileName ErrorFileName .
  33.  
  34. options results
  35.  
  36.  
  37. /* Get the first error */
  38.  
  39. if open(logfile, ErrorFileName, 'R') then do
  40.  
  41.     if eof(logfile) then do   /* There were no errors */
  42.     FileName = SourceFileName
  43.     LineNo = 1
  44.     ColumnNo = 1
  45.     ErrorText = "No Errors"
  46.     end; else do
  47.         ErrorString = readln(logfile)
  48.  
  49.         /* This first test is just a reminder, in case you want to */
  50.         /* process all errors.  "Abort" would never come first.    */
  51.  
  52.         if ErrorString = "Compilation Aborted" then do
  53.             address command 'delete >nil:' outputfile
  54.             'okay1 Compilation Aborted'
  55.             exit
  56.         end
  57.  
  58.         if ErrorString ~= "" then do
  59.             parse var ErrorString '"' FileName '" At ' LineNo,
  60.                                        ',' ColumnNo ' :' ErrorText
  61.     end; else do
  62.         FileName = SourceFileName
  63.         LineNo = 1
  64.         ColumnNo = 1
  65.         ErrorText = "No Errors"
  66.     end
  67.     end
  68.     close(logfile)
  69. end; else do
  70.     say 'Could not open error file'
  71.     exit
  72. end
  73.  
  74. /* Strip the directory and volume name for comparisons */
  75.  
  76. JustFileName = Right(FileName,Length(FileName)-,
  77.             Max(LastPos('/',FileName),LastPos(':',FileName)))
  78.  
  79.  
  80. /* If CygnusEd isn't loaded, load it */
  81.  
  82. if ~show(Ports,'rexx_ced') then do
  83.     address command Ed FileName
  84.     do until show(Ports, 'rexx_ced')
  85.     address command wait 1
  86.     end;
  87. end; else do
  88.  
  89. /* If CED was loaded, we want to activate it, then check all */
  90. /* of the open views for the file that we've been compiling. */
  91.  
  92.     address 'rexx_ced'
  93.     cedtofront
  94.     status 66
  95.     views = result
  96.  
  97.     found = 0
  98.     i = 1
  99.     do until found | (i > views)
  100.     status 21
  101.     found = found | (JustFileName = result)
  102.     if ~found then 'Next view'
  103.     i = i + 1
  104.     end
  105.  
  106. /* If it wasn't found, then load it.  If the current view is */
  107. /* not empty, create a new view.                             */
  108.  
  109.     if ~found then do
  110.     status 21
  111.     if result ~= "" then 'Open New'
  112.     'Open ' FileName
  113.     end
  114. end
  115.  
  116. /* Display the error */
  117.  
  118. address 'rexx_ced'
  119.  
  120. 'jumpto' LineNo 1
  121. do for ColumnNo
  122.     'right'
  123. end
  124.  
  125. 'okay1  Error:' || ErrorText
  126.  
  127. /* Delete the temporary files */
  128.  
  129. address command 'delete >Nil:' ErrorFileName
  130. address command 'delete >Nil:' OutputFileName
  131.  
  132.