/* ** $VER: ErrorStep.ttx 1.0 (15.6.92) ** By Kenneth Yarnall. This code may be freely distributed. ** ** Step to the next SAS/C (tm) error from within TurboText (tm). ** Should be bound to a key/menu entry (see TTX_SASC.dfn) and run from a ** TurboText window containing the file being compiled. ** ** This takes a single argument, which should be one of the commands to ** move scmsg to a new message (next, prev, top, bottom, or blank for the ** current message). This argument (stored in the variable 'movement') is ** Interpret'ed and sent to scmsg unadulterated. */ Options RESULTS /* ** Get the current TurboText port and store it */ primo.port = Address() SetClip('primo_port', primo.port) /* ** Get the command line argument */ parse arg movement /* ** Get basic info from scmsg */ Address 'SC_SCMSG' /* ** Move depending on the argument given, and analyse the new error. */ Interpret movement /* ** Get the name of the main file from scmsg. If there is no file name, ** there are no errors. */ 'file' main.path = RESULT if main.path = "" /* No messages in the Browser */ then do Address VALUE primo.port SetStatusBar "No SAS/C errors" exit end /* ** Now check for an alternate file */ 'altfile' alt.path = RESULT /* ** Retrieve the number and text of the message from scmsg. */ 'number' err.num = RESULT 'text' err.text = RESULT /* ** Process the main file. */ Call MainFile /* ** Process the alternate file, if any. ** ** The reason I put these two sections into "subroutines" is so that the ** order in which they are called can easily be switched. */ if alt.path ~= "" then Call AltFile /* All there is to it. */ exit 0 /*-------------------------------------------------------------------*/ MainFile: Address SC_SCMSG 'line' main.line = RESULT /* Now find the filename portion of main.path */ Call FindFileName main.path main.name = RESULT /* ** Find the window containing the main file. */ Call FindFilePort main.name,main.path main.port = RESULT if main.port = "" then Return Address VALUE main.port Window2Front ActivateWindow Move FOLDS main.line SetStatusBar err.num||': '||err.text Return /*-------------------------------------------------------------------*/ AltFile: Address SC_SCMSG 'altline' alt.line = RESULT /* Now find the filename portion of alt.path */ Call FindFileName alt.path alt.name = RESULT /* ** Find the window containing the alternate file. */ Call FindFilePort alt.name,alt.path alt.port = RESULT if alt.port = "" then Return Address VALUE alt.port Window2Front ActivateWindow Move FOLDS alt.line SetStatusBar err.num||': '||err.text Return /*-------------------------------------------------------------------*/ /* ** FindFileName -- Extracts the filename part of a path specification. */ FindFileName: PROCEDURE parse arg path dirend = LastPos('/', path) if dirend = 0 then dirend = Pos(':', path) if dirend ~= 0 then name = SubStr(path, dirend+1) else name = path return name /*-------------------------------------------------------------------*/ /* ** FindFilePort -- Finds the TurboText port corresponding to a file, or ** tries to open the file if it is not in memory. */ FindFilePort: PROCEDURE parse arg file,path Address TurboText GetPort file if RESULT = "RESULT" then do Address VALUE GetClip('primo_port') promptstr = '"Load ' || file || '?"' RequestBool '"TTX <=> SAS/C"' promptstr if RESULT = "YES" then do OpenDoc NAME path Return RESULT end else Return "" end else Return RESULT