home *** CD-ROM | disk | FTP | other *** search
-
- /*
- * $VER: lsx.ttx 1.0 (30.05.91)
- *
- * Tabsize = 4
- *
- * Opens port to communicate with LC, parses LC error file, and opens TTX
- * windows for associated files in error. Appends TTX_LSE_MAC.dfn keyboard for
- * accessing macros. Does not call WindowOrg to organize the windows. Acts as
- * host for the other commands (Next Error, Previous Error, etc.).
- *
- * Note that 'F' or "L' are appended to error type for the first and last
- * errors respectively.
- *
- * Written by J. L. Moulton
- *
- * For SAS 5.10a - Haven't checked earlier versions.
- */
-
-
- options results
-
- /* Make sure support is loaded and get our TTX port */
-
- if (~show('L','rexxsupport.library')) then do
- call addlib('rexxsupport.library',0,-30,0)
- if result = 0 then do
- myerrmsg = 'Could not open rexxsupport.library.'
- signal errexit
- end
- end
-
- invkport = address()
-
- /* Open an host port and lockout. */
-
- hostport = openport('LSE_TTX_PORT')
- if (hostport = '00000000'x) then exit(100)
- SetStatusBar "We 'un's be busy..."
- SetInputLock ON
- SetDisplayLock ON
-
- /*
- *
- * We are invoked because LC's "RUN >NIL: LSE" command has been patched to:
- * "TTX Macro lsx"
- *
- * which causes this macro to be run as a TTX startup macro. So, open a port to
- * emulate LSE. Read the packets from LC which specify the compiled file and the
- * name of the errfile, and close the port.
- *
- * For this to work, SASCOPTS or LC cmd line must specify -E = invoke lse on
- * error, and TTX must be in the current path. Obviously, the aforementioned
- * patch must be implemented, and this macro must be in path.
- *
- */
-
-
- lcport = openport('Lse')
- if (lcport = '00000000'x) then exit(100)
-
-
- /* Append kbd defs for commands to this host port (LSE_TTX_PORT) */
-
- OpenDefinitions NAME 'TurboText:Support/TTX_LSE_MAC.dfn'
-
-
- do forever
-
- call waitpkt('Lse')
- pkt = getpkt('Lse')
- if pkt = '00000000'x then iterate
-
- arg = getarg(pkt)
- parse var arg arg '00'x
- pkt_type = left(arg,2)
- if (pkt_type = 'OW') then parse var arg 'OW UC' compilename .
- if (pkt_type = 'PM') then parse var arg 'PM UCO' compilename .
- if (pkt_type = 'LE') then parse var arg 'LE ' lcerrs
- if (pkt_type = 'NE') then do
- compilename = left(compilename,length(compilename) - 1)
- UpdateView
- call reply(pkt,0)
- leave
- end
- call reply(pkt,0)
- end
- call closeport('Lse')
-
-
- /*
- * Now parse the error file and build a table of files in error.
- *
- * This content addressable stuff is neat!
- */
-
- SetStatusBar "Parsing SAS error file..."
- toterr = 0
- open(LEF,lcerrs,'R')
- do until eof(LEF)
-
- /* Read line from error file - if line from source,
- then also read error text line */
-
- feln = readln(LEF)
- if (index(feln,'0f'x) = 1) then leave
- if (((words(feln) < 5)) | ((word(feln,3) ~= 'Warning') & (word(feln,3) ~= 'Error'))) then do
- fert = readln(LEF)
- parse var fert file lineno type errno errtext
- column = index(feln,'1b'x)
- end
- else do
- parse var feln file lineno type errno errtext
- column = 1
- end
-
- /* Build stem variables - we don' NEED no stinkin' clip variables (but we
- shoulda had 'em) */
-
- toterr = toterr + 1
- serr.toterr.f = file
- serr.toterr.l = lineno
- serr.toterr.c = column
- serr.toterr.t = type
- serr.toterr.e = errno
- serr.toterr.x = errtext
- thefiles.file = 0
- thefiles.file.tprt = "NOPE!"
- end
-
-
- /* We're all parsed off now, so calculate which files to load and load them. */
-
- SetStatusBar "Loading file(s)..."
- GetCurrentDir
- ldir = result
- SetInputLock OFF
- SetDisplayLock OFF
-
- /* Open the SAS error file for reference */
-
- OpenFile NAME lcerrs
-
-
- do avar = 1 to toterr
- cf = serr.avar.f
- if (thefiles.cf = 0) then do
- if (index(cf,':') = 0) then dcf = ldir || cf
- else dcf = cf
-
- OpenDoc NAME dcf
- thefiles.cf.tprt = result
- thefiles.cf = 1
- end
- end
-
-
- /* Now position to first error. */
-
- CurrErr = 1
- call showerr()
-
-
- /* Monitor port for commands - what was that other instruction? Select? */
-
- do forever
-
- call waitpkt ('LSE_TTX_PORT')
- pkt = getpkt('LSE_TTX_PORT')
- if pkt = '00000000'x then iterate
-
- arg = getarg(pkt)
- parse var arg arg '00'x
-
- /* NXT command - display next error - attached to L_Am 1 key */
-
- if (arg = 'NXT') then do
- CurrErr = CurrErr + 1
- if (CurrErr > toterr) then CurrErr = toterr
- call showerr()
- call reply(pkt,0)
- end
-
- /* PRV command - display previous error - attached to L_Am 2 key */
-
- if (arg = 'PRV') then do
- CurrErr = CurrErr - 1
- if (CurrErr < 1) then CurrErr = 1
- call showerr()
- call reply(pkt,0)
- end
-
- /* AGN command - display same error again - attached to L_Am 3 key */
-
- if (arg = 'AGN') then do
- call showerr()
- call reply(pkt,0)
- end
-
- /* FST command - display first error - attached to L_Am 4 key */
-
- if (arg = 'FST') then do
- CurrErr = 1
- call showerr()
- call reply(pkt,0)
- end
-
- /* LST command - display last error - attached to L_Am 5 key */
-
- if (arg = 'LST') then do
- CurrErr = toterr
- call showerr()
- call reply(pkt,0)
- end
-
- /* SHE command - display SAS error file - attached to L_Am 6 key */
- /* Must use other method to sw from this window - it's a port thing */
-
- if (arg = 'SHE') then do
- address value invkport
- ActivateWindow
- Window2Front
- CenterView
- SetStatusBar '"'type errno errtext'"'
- call reply(pkt,0)
- end
-
- /* QUI command - Write changed files, close windows and quit -
- attached to L_Am Q key */
-
- if (arg = 'QUI') then do
- call reply(pkt,0)
-
- do avar = 1 to toterr
- cf = serr.avar.f
- if (thefiles.cf = 1) then do
- address value thefiles.cf.tprt
- ActivateWindow
- GetFileInfo
- parse var result dum changed .
- if changed = "YES" then SaveFile
- CloseDoc
- thefiles.cf = 0
- end
- end
-
- /* Close original window */
-
- address value invkport
- CloseDoc
-
- /* Let ARexx cleanup... */
-
- exit
- end
-
- end
-
-
-
-
- /* Display the current error. */
-
- showerr:
-
- file = serr.CurrErr.f
- lineno = serr.CurrErr.l
- column = serr.CurrErr.c
- type = serr.CurrErr.t
- errno = serr.CurrErr.e
- errtext = serr.CurrErr.x
- if (CurrErr = toterr) then type = 'L' || type
- if (CurrErr = 1) then type = 'F' || type
- address value thefiles.file.tprt
- ActivateWindow
- Window2Front
- SetDisplayLock ON
- Move FOLDS lineno column
- CenterView
- SetStatusBar '"'type errno errtext'"'
- SetDisplayLock OFF
- return()
-
-
-
- /* General error exit */
-
- errexit:
-
- SetStatusBar '"'myerrmsg '"'
- exit
-
-