Article 798 of alt.lang.teco: >In article <5nmkvn$6va$1@Jupiter.Mcs.Net>, Jorn Barger wrote: >> >> [1 J^P$L$$ >> J <.-Z; .,(S,$ -D .)FX1 @F^B $K :L I $ G1 L>$$ >> shoppa@alph02.triumf.ca (Tim Shoppa) writes: >To run the Jargon-file sample program, you'll need something closer >to ITS TECO. Which, as everyone knows, is the One True TECO :) :) :) Anyway, in case you're trying to grok the Jargon file example, this is what it means: [1 push Q-reg 1 on the PDL (aka "stack"). ITS TECO's stack automatically unwinds at the end of macro execution, so there's an automatic "]1" done at the end of the program. In other words, this makes an automatic local variable in this macro. J jump to beginning of buffer ^P$L$$ sort buffer. ^P is the sort command, which takes 3 (three!) string arguments, in this case "", "L", and "" (quotes added for clarity). Each string is taken to be a macro which positions dot somewhere useful to clue in TECO as to how to sort: . is assumed to initially be the start of the first sort field (beginning of buffer); the first macro positions . at the start of the sort key in the field (null here because we're sorting on the whole thing); the second moves . to after the key (L here moves to the next line); the third moves . to the end of the sort field (already there, so it's null in this case). (Just for completeness, I'll mention that the three string args get saved in Q-registers ..0, ..1, and ..2.) J jump back to beginning of (now-sorted) buffer. <.-Z; start loop from here to the end of the file... .,( now here's something you can't do (I think) in DEC TECO... a whole series of commands can be set in parens to have them execute and the return value of the *last* command is merged with the values to the left of the parens. So, the parenthesized expression (S,$ -D .) searches for a comma (S,$), deletes it (-D) and returns the current position (where the comma used to be). so the whole thing: .,(S,$ -D .) is a range from the inital location (start of the line) through where the comma is (well...was, since we're deleting that at the same time). This range of positions is then passed on to the FX command: FX1 This cuts the text to Q-register 1. It's like a combination of the X and K commands, i.e., x,yFX1 == x,yX1 x,yK @F^B In ITS TECO, note that @ is a general modifier flag just like : is. In DEC TECO, @ means to use an alternate string delimiter. In ITS TECO, it *usually* means that, but many commands use it for other things. With the @ flag, @F^B searches the buffer for the first character NOT in its string argument. So: @F^B $ searches in the buffer from . forward to the first non-space. It returns the range from . to that character. This range is then passed on to: K which deletes all those characters (i.e., eats up the space after where the comma used to be). This leaves just the first name on the line (the last name is in register 1 at this point). :L You probably know what L does, but ITS TECO adds a : flag to it which moves you to the end of the current line rather than the start of the next line. This is better than saying LRR, since you may not be on a system with a 2-byte end of line (CRLF). I $ Insert a space after the last name. G1 Paste the contents of Q-register 1 (last name) into the buffer. L Go to the start of the next line. > End loop. So you can see that ITS TECO has a few nifty features over DEC TECO. Of course, DEC TECO is the popular one that most people know how to use. As a little programming project, I'm writing an implementation of ITS TECO for Unix with modernized features added and ITS-specific things dropped. I'm not sure how soon it'll be done, but it's a fun project. I'm probably going to have make an X interface for it, just so I can draw some "console switches" on the screen for the FS DATA SWITCHES$ command to read. :) Oh, well... hope that helped you figure out the Jargon File program. --steve -- Steve Willoughby * Intel MD6 | "Maybe not eating people is the first step steve@ichips.intel.com | towards making new friends." Unix Systems Administrator | --Omnipotus (_The_Tick_) MD6 E-Mail Postmaster |