home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff297.lzh / DevKit / Rexx / NextError.ced < prev    next >
Text File  |  1989-12-29  |  4KB  |  149 lines

  1. /************************************************************************
  2.  *
  3.  * NextError.ced                    Copyright (c) 1989, Peter Cherna
  4.  *
  5.  * ARexx program that scans the AztecC.err file put out by the Aztec C
  6.  * Version 3.6a compiler, and puts the cursor on successive errors,
  7.  * opening a requester with the error message text.
  8.  *
  9.  * Version 1.33:  May 7, 1989        Release 1.2:  August 29, 1989
  10.  *
  11.  ************************************************************************/
  12.  
  13.  
  14.  
  15. /* Allow CygnusEd to pass status variables */
  16. options results
  17.  
  18. /* Tell ARexx to talk to CygnusEd */
  19. address 'rexx_ced'
  20.  
  21. cr = '0A'X
  22. tabchar = '09'X
  23.  
  24. if open('errfile','AztecC.err') then
  25. DO
  26.     offset = getclip('ErrorOffset')
  27.  
  28.     offset = seek('errfile',offset,'B')
  29.     errorstr = readln('errfile')
  30.     offset = seek('errfile',0,'C')
  31.     call setclip 'ErrorOffset',offset
  32.  
  33.     done = 0
  34.     DO until done = 1
  35.         if length(errorstr) > 1 then
  36.         DO    
  37.             /*    For Aztec C, the error file contains lines of the form
  38.                 "filename:line:char:error:errormsg"
  39.                 where filename is the name of the source module, line
  40.                 is the line number of the error, char is the character
  41.                 position of the error, error is the error number, and
  42.                 errormsg is the error message.
  43.                 We must be careful because the filename may contain a
  44.                 colon.  To begin, we assume it does, and parse accordingly: */
  45.  
  46.             parse var errorstr root ':' file ':' line ':' char ':' error ':' errormsg
  47.     
  48.             /*    Check if file's name had no colon.  True if 5th colon not
  49.                 found or very far over (it could be part of error msg.)
  50.                 If this is so, then parse over again */
  51.  
  52.             if (length(errormsg) = 0) | (length(error) > 4) then
  53.             DO
  54.                 root = ''
  55.                 parse var errorstr file ':' line ':' char ':' error ':' errormsg
  56.             END
  57.             else
  58.                 root = root':'
  59.  
  60.             sourcefile = file
  61.             /*    Strip off any leading directories: */
  62.             slash = lastpos('/',sourcefile)
  63.             if (slash > 0) then
  64.                 sourcefile = substr(sourcefile,slash+1)
  65.  
  66.             /*    Get current file's name: */
  67.             status 21
  68.             if upper(sourcefile) ~= upper(result) then
  69.             DO
  70.                 /* Find out how many views are displayed */
  71.                 status 66
  72.  
  73.                 /* Try to find the view containing the error file */
  74.                 DO numwins=result-1 to 1 by -1 until upper(result) = upper(sourcefile)
  75.                     next view
  76.                     /*    Get current file's name: */
  77.                     status 21
  78.                 END
  79.  
  80.                 /* If we can't find the file, then ask to open it */
  81.                 if upper(result) ~= upper(sourcefile) then
  82.                 DO
  83.                     next view        /* bring back to original view */
  84.                     okay2 "Error in line" line "of file" sourcefile || cr || errormsg || cr || "Bring it in?"
  85.                     if result = 1 then
  86.                     DO
  87.                         open new
  88.                         open root || file
  89.                     END
  90.                     else
  91.                     DO
  92.                         errorstr = readln('errfile')
  93.                         offset = seek('errfile',0,'C')
  94.                         call setclip 'ErrorOffset',offset
  95.                     END
  96.                 END
  97.             END
  98.  
  99.             /*    Get current file's name: */
  100.             status 21
  101.             if upper(sourcefile) = upper(result) then
  102.             DO
  103.                 /*    We want to put the cursor on the line containing the
  104.                     error.  Check if we're already there.  Get the current
  105.                     line (relative to first line = 0) */
  106.                 status 47
  107.  
  108.                 if (line ~= result+1) then
  109.                     jumpto line 1
  110.  
  111.                 /*    Get tab size */
  112.                 status 8
  113.                 tabsize = result
  114.  
  115.                 /*    Get contents of current line */
  116.                 status 55
  117.                 tab = 0
  118.                 DO until tab = 0
  119.                     tab = index(result,tabchar,tab+1)
  120.                     if tab > 0 then char = char + tabsize - 1
  121.                 END
  122.  
  123.                 jumpto line char+1
  124.  
  125.                 okay2 root || file':  Line' line', Error' error || cr || errormsg || cr'Go to next error?'
  126.                 if result = 0 then
  127.                     done = 1
  128.                 else
  129.                 DO
  130.                     errorstr = readln('errfile')
  131.                     offset = seek('errfile',0,'C')
  132.                     call setclip 'ErrorOffset',offset
  133.                 END
  134.             END
  135.         END
  136.         else
  137.         DO
  138.             okay1 'No more errors.'
  139.             call setclip 'ErrorOffset','0'
  140.             done = 1
  141.         END
  142.     END
  143.  
  144.     call close 'errfile'
  145. END
  146. else
  147.     okay1 'Error Messages not found.'
  148. exit
  149.