home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 531.lha / TurboText_Utils / ByeLSE / lsx.ttx < prev    next >
Encoding:
Text File  |  1991-07-04  |  6.1 KB  |  293 lines

  1.  
  2. /*
  3.  *     $VER: lsx.ttx 1.0 (30.05.91)
  4.  * 
  5.  *    Tabsize = 4
  6.  *
  7.  *     Opens port to communicate with LC, parses LC error file, and opens TTX
  8.  *     windows for associated files in error. Appends TTX_LSE_MAC.dfn keyboard for
  9.  *     accessing macros. Does not call WindowOrg to organize the windows. Acts as
  10.  *     host for the other commands (Next Error, Previous Error, etc.).
  11.  *  
  12.  *  Note that 'F' or "L' are appended to error type for the first and last
  13.  *  errors respectively.
  14.  *  
  15.  *     Written by J. L. Moulton
  16.  * 
  17.  *  For SAS 5.10a - Haven't checked earlier versions.
  18.  */
  19.  
  20.  
  21. options results
  22.  
  23. /* Make sure support is loaded  and get our TTX port */
  24.  
  25. if (~show('L','rexxsupport.library')) then do
  26.     call addlib('rexxsupport.library',0,-30,0)
  27.     if result = 0 then do
  28.         myerrmsg = 'Could not open rexxsupport.library.'
  29.         signal errexit
  30.     end
  31. end
  32.  
  33. invkport = address()
  34.  
  35. /* Open an host port and lockout. */
  36.  
  37. hostport = openport('LSE_TTX_PORT')
  38. if (hostport = '00000000'x) then exit(100)
  39. SetStatusBar "We 'un's be busy..."
  40. SetInputLock ON
  41. SetDisplayLock ON
  42.  
  43. /* 
  44.  * 
  45.  * We are invoked because LC's "RUN >NIL: LSE" command has been patched to:
  46.  *                             "TTX Macro lsx"
  47.  * 
  48.  * which causes this macro to be run as a TTX startup macro. So, open a port to
  49.  * emulate LSE. Read the packets from LC which specify the compiled file and the
  50.  * name of the errfile, and close the port.
  51.  * 
  52.  * For this to work, SASCOPTS or LC cmd line must specify -E = invoke lse on
  53.  * error, and TTX must be in the current path. Obviously, the aforementioned
  54.  * patch must be implemented, and this macro must be in path.
  55.  * 
  56.  */
  57.  
  58.  
  59. lcport = openport('Lse')
  60. if (lcport = '00000000'x) then exit(100)
  61.  
  62.  
  63. /* Append kbd defs for commands to this host port (LSE_TTX_PORT) */
  64.  
  65. OpenDefinitions NAME 'TurboText:Support/TTX_LSE_MAC.dfn'
  66.  
  67.  
  68. do forever
  69.  
  70.     call waitpkt('Lse')
  71.     pkt = getpkt('Lse')
  72.     if pkt = '00000000'x then iterate
  73.  
  74.     arg = getarg(pkt)
  75.     parse var arg arg '00'x
  76.     pkt_type = left(arg,2)
  77.     if (pkt_type = 'OW') then parse var arg 'OW UC' compilename .
  78.     if (pkt_type = 'PM') then parse var arg 'PM UCO' compilename .
  79.     if (pkt_type = 'LE') then parse var arg 'LE ' lcerrs
  80.     if (pkt_type = 'NE') then do
  81.         compilename = left(compilename,length(compilename) - 1)
  82.         UpdateView
  83.         call reply(pkt,0)
  84.         leave
  85.     end
  86.     call reply(pkt,0)
  87. end
  88. call closeport('Lse')
  89.  
  90.  
  91. /* 
  92.  *     Now parse the error file and build a table of files in error.
  93.  *  
  94.  *  This content addressable stuff is neat!
  95.  */
  96.  
  97. SetStatusBar "Parsing SAS error file..."
  98. toterr = 0
  99. open(LEF,lcerrs,'R')
  100. do until eof(LEF)
  101.  
  102. /*    Read line from error file - if line from source,
  103.     then also read error text line */
  104.  
  105.     feln = readln(LEF)
  106.     if (index(feln,'0f'x) = 1) then leave
  107.     if (((words(feln) < 5)) | ((word(feln,3) ~= 'Warning') & (word(feln,3) ~= 'Error'))) then do
  108.         fert = readln(LEF)
  109.         parse var fert file lineno type errno errtext
  110.         column = index(feln,'1b'x)
  111.     end
  112.     else do
  113.         parse var feln file lineno type errno errtext
  114.         column = 1
  115.     end
  116.  
  117. /* Build stem variables - we don' NEED no stinkin' clip variables (but we 
  118.    shoulda had 'em) */
  119.  
  120.     toterr = toterr + 1
  121.     serr.toterr.f = file
  122.     serr.toterr.l = lineno
  123.     serr.toterr.c = column
  124.     serr.toterr.t = type
  125.     serr.toterr.e = errno
  126.     serr.toterr.x = errtext
  127.     thefiles.file = 0
  128.     thefiles.file.tprt = "NOPE!"
  129. end
  130.  
  131.  
  132. /* We're all parsed off now, so calculate which files to load and load them. */
  133.  
  134. SetStatusBar "Loading file(s)..."
  135. GetCurrentDir
  136. ldir = result
  137. SetInputLock OFF
  138. SetDisplayLock OFF
  139.  
  140. /* Open the SAS error file for reference */
  141.  
  142. OpenFile NAME lcerrs
  143.  
  144.  
  145. do avar = 1 to toterr
  146.     cf = serr.avar.f
  147.     if (thefiles.cf = 0) then do
  148.         if (index(cf,':') = 0) then dcf = ldir || cf
  149.         else dcf = cf
  150.  
  151.         OpenDoc NAME dcf
  152.         thefiles.cf.tprt = result
  153.         thefiles.cf = 1
  154.     end
  155. end
  156.  
  157.  
  158. /* Now position to first error. */
  159.  
  160. CurrErr = 1
  161. call showerr()
  162.  
  163.  
  164. /* Monitor port for commands - what was that other instruction? Select? */
  165.  
  166. do forever
  167.  
  168.     call waitpkt ('LSE_TTX_PORT')
  169.     pkt = getpkt('LSE_TTX_PORT')
  170.     if pkt = '00000000'x then iterate
  171.  
  172.     arg = getarg(pkt)
  173.     parse var arg arg '00'x
  174.  
  175. /* NXT command - display next error - attached to L_Am 1 key */
  176.  
  177.     if (arg = 'NXT') then do
  178.         CurrErr = CurrErr + 1
  179.         if (CurrErr > toterr) then CurrErr = toterr
  180.         call showerr()
  181.         call reply(pkt,0)
  182.     end
  183.  
  184. /* PRV command - display previous error - attached to L_Am 2 key */
  185.  
  186.     if (arg = 'PRV') then do
  187.         CurrErr = CurrErr - 1
  188.         if (CurrErr < 1) then CurrErr = 1
  189.         call showerr()
  190.         call reply(pkt,0)
  191.     end
  192.  
  193. /* AGN command - display same error again - attached to L_Am 3 key */
  194.  
  195.     if (arg = 'AGN') then do
  196.         call showerr()
  197.         call reply(pkt,0)
  198.     end
  199.  
  200. /* FST command - display first error - attached to L_Am 4 key */
  201.  
  202.     if (arg = 'FST') then do
  203.         CurrErr = 1
  204.         call showerr()
  205.         call reply(pkt,0)
  206.     end
  207.  
  208. /* LST command - display last error - attached to L_Am 5 key */
  209.  
  210.     if (arg = 'LST') then do
  211.         CurrErr = toterr
  212.         call showerr()
  213.         call reply(pkt,0)
  214.     end
  215.  
  216. /* SHE command - display SAS error file - attached to L_Am 6 key */
  217. /* Must use other method to sw from this window - it's a port thing */
  218.  
  219.     if (arg = 'SHE') then do
  220.         address value invkport
  221.         ActivateWindow
  222.         Window2Front
  223.         CenterView
  224.         SetStatusBar '"'type errno errtext'"'
  225.         call reply(pkt,0)
  226.     end
  227.  
  228. /* QUI command - Write changed files, close windows and quit - 
  229.                 attached to L_Am Q key */
  230.  
  231.     if (arg = 'QUI') then do
  232.         call reply(pkt,0)
  233.  
  234.         do avar = 1 to toterr
  235.             cf = serr.avar.f
  236.             if (thefiles.cf = 1) then do
  237.                 address value thefiles.cf.tprt
  238.                 ActivateWindow
  239.                 GetFileInfo
  240.                 parse var result dum changed .
  241.                 if changed = "YES" then SaveFile
  242.                 CloseDoc
  243.                 thefiles.cf = 0
  244.             end
  245.         end
  246.  
  247. /* Close original window */
  248.  
  249.         address value invkport
  250.         CloseDoc
  251.  
  252. /* Let ARexx cleanup... */
  253.  
  254.         exit
  255.     end
  256.  
  257. end
  258.  
  259.  
  260.  
  261.  
  262. /* Display the current error. */
  263.  
  264. showerr:
  265.  
  266. file    = serr.CurrErr.f
  267. lineno    = serr.CurrErr.l
  268. column    = serr.CurrErr.c
  269. type    = serr.CurrErr.t
  270. errno    = serr.CurrErr.e
  271. errtext    = serr.CurrErr.x
  272. if (CurrErr = toterr) then type = 'L' || type
  273. if (CurrErr = 1) then type = 'F' || type
  274. address value thefiles.file.tprt
  275. ActivateWindow
  276. Window2Front
  277. SetDisplayLock ON
  278. Move FOLDS lineno column
  279. CenterView
  280. SetStatusBar '"'type errno errtext'"'
  281. SetDisplayLock OFF
  282. return()
  283.  
  284.  
  285.  
  286. /*    General error exit */
  287.  
  288. errexit:
  289.  
  290. SetStatusBar '"'myerrmsg '"'
  291. exit
  292.  
  293.