/* ARexx macro for Textra & SAS/C

   'Next Error'

   Nothing fancy.  Just ask SCMSG for the Next error in its list.
*/

options failat 21

if (~show('P',SC_SCMSG)) then do
    address command 'run <nil: >nil: SCMSG'
    address command waitforport SC_SCMSG
end

address SC_SCMSG        /* Talk to the SAS/C Message Browser.  Assumes
                           SCMSG is already running... */

'NEXT'

if (rc < 20) then do    /* Move to the "Next" error message, while there's
                           one to move to... */

    options results     /* We *want* results. */

    'FILE'              /* Get the name of the file this error occurred in... */

    file = result       /* ... and save it. */

    'LINE'              /* Get the line number this error occurred on... */

    line = result       /* ... and save it. */

    options             /* We're not interested in results anymore. :-) */

    address TEXTRA          /* Talk to Textra again. */

    openfile file       /* Tell Textra to open the file, or pop the window
                           with this file in it to the front. */

    gotoxy1 1 line      /* Tell Textra to put the cursor on the offending
                           line. */
end
else do
    address TEXTRA

    notify 'a'x||"NO MORE ERRORS!  (Bottom of error list reached.)"
end

