perm filename EINIT.CMD[1,3]14 blob sn#472001 filedate 1979-09-11 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00012 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00003 00002	αβxCOMMENT  This is the (new) system library of ETV macros.  The
C00005 00003	αβxcomment REF - Horizontal attach and copy
C00007 00004	αβxcomment REF, DON - Reverse a line, reverse an FMUNGE character ↔
C00009 00005	αβxcomment REF - word transposition. ↔
C00012 00006	αβxcomment REF - Find in a list of files.  Take the cursor and point it to the
C00016 00007	αβxcomment REF - Saving a readonly page    SAVE.
C00017 00008	αβxcomment REF - Convert a directory to file names.
C00024 00009	αβxcomment REF - Caps to small CTS this line, caps to smalls TLCTS↔
C00026 00010	αβxcomment REF - small from caps on this page Much faster than the previous stuff.↔
C00027 00011	αβxCOMMENT DON,KS QSORT -  Quicksort
C00038 00012	αβXCOMMENT ROB,KS - BELCH: BURP an entire file		11-Sep-79
C00041 ENDMK
C⊗;
αβxCOMMENT  This is the (new) system library of ETV macros.  The
librarian is REF.  Please send (copiously commented) additions to him.

Most of the macros in this file can be used by loading the appropriate
macro page into your E core image.  This is done with the extended
execute command.  Thus, to get the horizontal attachment and copying
macros on the next page, one would type to E:
<control>xEXE [1,3](3)<carriage return>

Some of these macros, however, might require modification to suit your
purposes.  For example, you probably would want to use the find macros
on page 8 to find stuff in your own files.  Copy that macro page to your
own file, modify the macros to suit yourself, and then execute that page.

Have fun.
⊗↔
αβxcomment REF - Horizontal attach and copy

These macros are for horizontal attachments.  Calling the macro HA inserts
a mark in the line (a <vt>), and aborts.  Resuming under another
character picks up everything from the original mark to that character,
and places it in the horizontal attachment buffer.  Doing a further
"resume", or calling the macros HD or HAB will deposit that text in a line.

Doing a deposit at the end of a line unfortunately leaves you in line
insert mode.

HC will do a copy, rather than an attach.  HSAVE will save your horizontal
attach buffer in the macro HD1.  Invoking the macro HD will also deposit
your horizontal attach buffer.
⊗↔

αXDEFINE HA⊗↔
αi⊗←αs⊗←αxabort⊗↔β⊗←α⊗↑β⊗↔αβuαs⊗←αdβ⊗↔αβa⊗↔αβe
β⊗αβiα⊗=⊗αs⊗←α⊗↔αaαxred hab⊗↔αβk
αβuαβuαβxjo⊗↔αs⊗←αd
αβxabort⊗↔αβzhd⊗↔
αβ⊗↓

αXDEFINE HD⊗↔
αβzhab⊗↔αβ⊗↓

αXDEFINE HC⊗↔
αi⊗←αs⊗≠αxabort⊗↔
β⊗↔αβuαs⊗←αdβ⊗↔αi⊗αiα⊗=⊗αs⊗←α⊗↔αβaαβxred hab⊗↔αβeα2αdα⊗=⊗↑⊗↑⊗↑αβuαβ3αβxjo⊗↔αβxabort⊗↔
αβzhd⊗↔
αβ⊗↓

αXDEFINE HSAVE⊗↔
αβxatt hab⊗↔αβxred hab1⊗↔αβk
αβ⊗↓

αXDEFINE HD1⊗↔
αβzhab1⊗↔αβ⊗↓

αxsay  HA HC⊗↔
αβxcomment REF, DON - Reverse a line, reverse an FMUNGE character ⊗↔

αβxcomment The macro REVERSe reverses the current "arrow" line.  The line should
have at least two characters on it.
⊗↔

αXDEFINE revup⊗↔
αβ-αβa⊗↔
αβ⊗↓

αβxcomment point the arrow at the line to be reversed ⊗↔
αXDEFINE REVERS⊗↔
αβaαβ1αβxbreak 1⊗↔αxargument attsiz.⊗↔αxset revlng⊗↔
αxargument revlng⊗↔αβzrevup⊗↔αxargument revlng⊗↔αβu
αxargument revlng⊗↔αβxjoin⊗↔
αβ⊗↓

αβxcomment If you're anywhere on a page of an FMUNGE star-dot file,
the macro CHRREV will reverse the character on that page.
⊗↔

αXDEFINE chrrv1⊗↔
⊗↔αzrevers⊗↔
αβ⊗↓

αXDEFINE CHRREV⊗↔
αlαxnonempty⊗↔αβuαxargument lines.⊗↔αxset revlng⊗↔
αxargument line.⊗↔αxsubtract revlng⊗↔αxargument revlng⊗↔αzchrrv1⊗↔
αβ⊗↓

αxsay  REVERS CHRREV⊗↔
αβxcomment REF - word transposition. ⊗↔

αβxcomment move the cursor under the first of two words in the MIDDLE of
a line to be transposed, then execute ⊗↔

αXDEFINE TRANSP⊗↔
β⊗↔αs α β⊗↔αs α β⊗↔
αβxcomment break the line around the two words⊗↔
αβ-αβaαβuαβe
αβxcomment grab the second and move it up ahead of the first⊗↔
αβuαβ3αβxjo⊗↔
αβxcomment go up a line and re-patch the world⊗↔
α⊗=αd
αβxcomment pick up the last part of the last line, leaving the cursor in a
useful place↔
αβ⊗↓

αxsay  TRANSP⊗↔
αβxcomment REF - Find in a list of files.  Take the cursor and point it to the
first of a list of files.  (one to a line) Will continue until either the
next blank line, or until the current string is found. ⊗↔

αβxdefine FLFIND⊗↔
αβxstopo⊗↔
αβzflfnd1⊗↔
αβ⊗↓

αβxdefine FLFND1⊗↔
αβ0αβxnonempty⊗↔
αβxpoint /-r/2p/1l⊗↔
αβzflfnd2⊗↔
αh
⊗↔
αβzflfnd1⊗↔
αβ⊗↓

αβxdefine flfnd2⊗↔
αβv
αβ*
αβxabort⊗↔
αβ⊗↓

αxsay  FLFIND⊗↔
αβxcomment REF - Saving a readonly page    SAVE.
	Its often useful to be able to save the world (write out in the
core pages) when in readonly mode, by leaving readonly mode, saving, and
then returning.  This macro turns it into one command.⊗↔

αβxdefine SAVE⊗↔
αβxreadw⊗↔
αβ.
αβxreado⊗↔
αβ⊗↓

αxSAY  SAVE⊗↔
αβxcomment REF - Convert a directory to file names.

FIXFIL Takes a page of directory information from WILD or DIR, and converts
it to a list of file names, one to a line.  Useful for editing directories. ⊗↔

αXDEFINE FFIL⊗↔
α6α .α3α [α3α β,α3α ]αK⊗↔⊗↔αβ⊗↓

αXDEFINE FIXFIL⊗↔
αβLαβxarg lines.⊗↔αβZFFIL⊗↔
αβLαF αβ\αβ∞⊗↔αβLαβ⊗↓

αxSAY  FIXFIL⊗↔
αβxcomment REF - Caps to small CTS; this line, caps to smalls TLCTS⊗↔

αβxcomment TLCTS changes all the captial letters on this line to small. ⊗↔
αβXdefine TLCTS⊗↔
αβxarg char.⊗↔αβxset tlctsR⊗↔
αβxcomment store the current character position in tlctsR⊗↔
α⊗=α⊗→
αβxarg chars.⊗↔
αβzcts⊗↔
α⊗→αxarg tlctsR⊗↔α 
αβxcomment and get back there ⊗↔
αβ⊗↓

αβxcomment CTS changes a captial letter to a small letter. ⊗↔
αβXdefine CTS⊗↔
αβxrapid⊗↔
αβxterse⊗↔
αβxstopone⊗↔
αβ#αβzcts1⊗↔
αβ1αβxabort⊗↔
αβ⊗↓

αβXdefine CTS1⊗↔
αβZCACHK⊗↔
αβ⊗↓

αβxdefine CACHK⊗↔
αβzCACHK1⊗↔
α 
αβ⊗↓

αβxdefine CACHK1⊗↔
αβ6αβ4αβxiflt ascii.⊗↔
αβ9αβ1αβxifgt ascii.⊗↔
αβxarg ascii.⊗↔
αβxset foo⊗↔
αβ3αβ2αβxadd foo⊗↔
αβxcharacter foo⊗↔
αβ2αβxabort⊗↔
αβ⊗↓

αβxsay  CTS TLCTS⊗↔
αβxcomment REF - small from caps on this page Much faster than the previous stuff.⊗↔

αxdefine small⊗↔
αxstopzero⊗↔
αlαfAαβ\aα∞⊗↔
αlαfBαβ\bα∞⊗↔
αlαfCαβ\cα∞⊗↔
αlαfDαβ\dα∞⊗↔
αlαfEαβ\eα∞⊗↔
αlαfFαβ\fα∞⊗↔
αlαfGαβ\gα∞⊗↔
αlαfHαβ\hα∞⊗↔
αlαfIαβ\iα∞⊗↔
αlαfJαβ\jα∞⊗↔
αlαfKαβ\kα∞⊗↔
αlαfLαβ\lα∞⊗↔
αlαfMαβ\mα∞⊗↔
αlαfNαβ\nα∞⊗↔
αlαfOαβ\oα∞⊗↔
αlαfPαβ\pα∞⊗↔
αlαfQαβ\qα∞⊗↔
αlαfRαβ\rα∞⊗↔
αlαfSαβ\sα∞⊗↔
αlαfTαβ\tα∞⊗↔
αlαfUαβ\uα∞⊗↔
αlαfVαβ\vα∞⊗↔
αlαfWαβ\wα∞⊗↔
αlαfXαβ\xα∞⊗↔
αlαfYαβ\yα∞⊗↔
αlαfZαβ\zα∞⊗↔
αxstopall⊗↔
αβ⊗↓

αxSAY  SMALL⊗↔
αβxCOMMENT DON,KS QSORT -  Quicksort
	4-Nov-78  0223 ⊗↔
αXCOMMENT	QSORT (QuickSort) -- Sort the lines on a page.

	The macro QSORT takes all lines on the current page (which may be one
of several incore pages) and sorts them based on a collating sequence determined
by the QCHMAP macro.  (The QCHMAP macro provided below simply maps lower-case
letters to their upper-case equivalents.)  The field sorted on is the entire
line; someday there may be facilities for specifying character positions, but
it doesn't really seem worth it.  Note: Lines which match on the first several
characters will be assumed equal and will be left unsorted (since the sort is
"stable", their relative order will be unchanged).  You'll be told if this
happens.

	QSORT is reasonably fast for small pages, say up to 100 lines or so.
Above that and the SSORT program is probably your best bet.  QSORT doesn't
destroy "marks", but it does affect various mode switches, leaving you with
-RAPID, -TERSE, -SILENT, STOPALL, CHECK, and a 5000-char UNDELETE buffer.
⊗↔

αXCOMMENT
	First step is to separate any empty lines, to save special-case
	testing in low-level routines.  Then we start recursion via QSORT1.
⊗↔
αXDEFINE QSORT⊗↔
	αXRAPID⊗↔
	αXTERSE⊗↔αXSILENT⊗↔α-αXCHECK⊗↔αXSTOPONE⊗↔α-αXUNDELETE⊗↔
	α0αXSET QLEVEL⊗↔
	αLβ⊗→β⊗↔α-αAα∞αZQEMPTY⊗↔⊗↔α-αPαEαβDαP
	αZQSORT1⊗↔
	αLα-αβD
	α-α5α0α0α0αXUNDELETE⊗↔αXCHECK⊗↔αXSTOPALL⊗↔α-αXTERSE⊗↔α-αXSILENT⊗↔
	α-αXRAPID⊗↔
αβ⊗↓

αXCOMMENT
	QEMPTY looks for an empty line and appends it onto the attach buffer.
	We first back up so that (a) we'll find the second of two consecutive
	blank lines and (b) we won't go to the next incore page (X EMPTY does
	so if given at end of page).
⊗↔
αXDEFINE QEMPTY⊗↔
	αUαXEMPTY⊗↔α+αA
αβ⊗↓

αXCOMMENT
	QSORT1 is the top recursive call; it sorts the current page based on the
	first char of each line, and uses QEQUAL to subsort on equality.  It returns
	at once if there are fewer than 2 lines, else it uses the median line to
	partition the other lines into 3 subpages and recurses.
⊗↔
αXDEFINE QSORT1⊗↔
	αXIFLT LINES.⊗↔
	α∞αLβ⊗→α-αPβ⊗→
	αXSET QVALUE←LINES.⊗↔α2αXDIVIDE QVALUE⊗↔
	αXARGUMENT QVALUE⊗↔⊗↔
	αV
	αXARGUMENT ASCII.⊗↔αZQCHMAP⊗↔αXSET QVALUE⊗↔
	αLαXARGUMENT LINES.⊗↔αZQSPLIT⊗↔
	α-αPαZQSORT1⊗↔
	αPαZQEQUAL⊗↔αLα-αβD
	αPαZQSORT1⊗↔
	αLα-αβD
αβ⊗↓

αXCOMMENT
	QSPLIT compares the first char of the current line with QVALUE and moves
	the line to the appropriate subpage.
⊗↔
αXDEFINE QSPLIT⊗↔
	αXARGUMENT ASCII.⊗↔αZQCHMAP⊗↔αXSET QVAL2⊗↔
	⊗↔
	αZQSPLT0⊗↔
αβ⊗↓

αXCOMMENT
	QSPLT0 decides where to put the line above us, whose QLEVELth char is QVAL2.
⊗↔
αXDEFINE QSPLT0⊗↔
	αXARGUMENT QVAL2⊗↔αXIFNE QVALUE⊗↔
	α-αAαXSET QLINE←LINE.⊗↔
	αZQLESS⊗↔
	αPα∞αLαE
	α-αPαXARGUMENT QLINE⊗↔αL
αβ⊗↓

αXCOMMENT
	QLESS moves the line above us to the previous page if QVAL2 < QVALUE, and
	also aborts our caller (QSPLT0) if that's the case.
⊗↔
αXDEFINE QLESS⊗↔
	αXARGUMENT QVAL2⊗↔αXIFLT QVALUE⊗↔
	αLαUαE
	αPαXARGUMENT QLINE⊗↔αL
	α2αXABORT⊗↔
αβ⊗↓

αXCOMMENT
	QEQUAL is called to subsort a page on which all lines are, so far, equal.
	It aborts at once if there's only one line, else it increments QLEVEL,
	snarfs all lines which contain only QLEVEL chars (just as QSORT snarfed all
	empty lines), and calls QSORT2 to sort the rest.
⊗↔
αXDEFINE QEQUAL⊗↔
	αXIFLT LINES.⊗↔
	αXADD QLEVEL⊗↔
	αLβ⊗→αCαUαXARGUMENT LINES.⊗↔αZQSNARF⊗↔α-αPαEαβDαP
	αZQSORT2⊗↔
	αLα-αβD
	αXSUBTRACT QLEVEL⊗↔
αβ⊗↓

αXCOMMENT
	QSNARF and QSNRF0 attaches the current line if it has only QLEVEL chars.
⊗↔
αXDEFINE QSNARF⊗↔
	αZQSNRF0⊗↔
	⊗↔
αβ⊗↓
αXDEFINE QSNRF0⊗↔
	αXARGUMENT QLEVEL⊗↔αXIFGE CHARS.⊗↔
	α+αAαU
αβ⊗↓

αXCOMMENT
	QSORT2 is the secondary recursive call; it sorts the current page based on
	the QLEVELth char of each line, and uses QEQUAL to subsort on equality.  It
	returns at once if there are fewer than 2 lines, else it uses the median
	line to partition the other lines into 3 subpages and recurses.
⊗↔
αXDEFINE QSORT2⊗↔
	αXIFLT LINES.⊗↔
	αZQDEEP⊗↔
	α∞αLβ⊗→α-αPβ⊗→
	αXSET QVALUE←LINES.⊗↔α2αXDIVIDE QVALUE⊗↔
	αXARGUMENT QVALUE⊗↔⊗↔
	αV
	αZQEVAL⊗↔
	αLαXARGUMENT LINES.⊗↔αZQSPLT2⊗↔
	α-αPαZQSORT2⊗↔
	αPαZQEQUAL⊗↔αLα-αβD
	αPαZQSORT2⊗↔
	αLα-αβD
αβ⊗↓

αXCOMMENT
	QDEEP tests whether we're getting too deep in recursion due to lines which
	match on a long leading string.  For now, if so, we leave the lines unsorted
	and issue a warning.
⊗↔
αXDEFINE QDEEP⊗↔
	α2α0αXIFLE QLEVEL⊗↔
	αXARGUMENT LINES.⊗↔αXSAY WARNING!! ⊗↔
	αXARGUMENT QLEVEL⊗↔αXSAY  lines match on their first ⊗↔
	αβXSAY  chars and are left unsorted.⊗↔
	α2αXABORT⊗↔
αβ⊗↓

αXCOMMENT
	QEVAL and QEVL0 figure out what the character is that's QLEVEL chars in on
	the current line, and leaves us one the line below.  It uses the line-editor
	if possible, since it's faster, but if it won't fit it uses cruder methods.
	The value is put into QVALUE.
⊗↔
αXDEFINE QEVAL⊗↔
	αZQEVL0⊗↔
	αCα1αXBREAK 1⊗↔αXARGUMENT QLEVEL⊗↔αβKα∞αXJOIN⊗↔αE
	αXARGUMENT ASCII.⊗↔αZQCHMAP⊗↔αXSET QVALUE⊗↔αβD
αβ⊗↓
αXDEFINE QEVL0⊗↔
	αXARGUMENT QLEVEL⊗↔α αXARGUMENT ASCII.⊗↔αZQCHMAP⊗↔αXSET QVALUE⊗↔⊗↔
	α2αXABORT⊗↔
αβ⊗↓

αXCOMMENT
	QSPLT2 is like QSPLIT except it looks at the QLEVELth char.
⊗↔
αXDEFINE QSPLT2⊗↔
	αZQEVAL2⊗↔
	αZQSPLT0⊗↔
αβ⊗↓

αXCOMMENT
	QEVAL2 and QEVL02 are the same as QEVAL except the value goes into QVAL2.
⊗↔
αXDEFINE QEVAL2⊗↔
	αZQEVL02⊗↔
	αCα1αXBREAK 1⊗↔αXARGUMENT QLEVEL⊗↔αβKα∞αXJOIN⊗↔αE
	αXARGUMENT ASCII.⊗↔αZQCHMAP⊗↔αXSET QVAL2⊗↔αβD
αβ⊗↓
αXDEFINE QEVL02⊗↔
	αXARGUMENT QLEVEL⊗↔α αXARGUMENT ASCII.⊗↔αZQCHMAP⊗↔αXSET QVAL2⊗↔⊗↔
	α2αXABORT⊗↔
αβ⊗↓

αXCOMMENT
	QCHMAP takes its argument (via the rep count) and maps it into a new value
	based on the collating sequence desired.  The result is returned by ending
	QCHMAP with an ARGUMENT command.  This particular version of QCHMAP simply
	converts lower-case letters to upper-case.  NOTE: Be sure to use doublebucky
	on numeric arguments in QCHMAP, since it's called from the line editor.
⊗↔
αXDEFINE QCHMAP⊗↔
	α#αXSET QCHARX⊗↔
	αβ1αβ2αβ3αXREMAINDER QCHARX⊗↔
	αβ9αβ7αXDIVIDE QCHARX⊗↔
	αβ-αβ3αβ2αXMULTIPLY QCHARX⊗↔
	α#αXARGUMENT QCHARX⊗↔
αβ⊗↓

αXCOMMENT
	QORDLT is used by QORDER to test for QCHAR1 being less than QCHAR2.  If
	so, we abort to QLESS, else we return.
⊗↔
αXDEFINE QORDLT⊗↔
	αXARGUMENT QCHAR1⊗↔αXIFLT QCHAR2⊗↔
	α2αβD
	α5αXABORT⊗↔
αβ⊗↓

αxsay  QSORT⊗↔
αβXCOMMENT ROB,KS - BELCH: BURP an entire file		11-Sep-79

(Original idea and simple minded implementation by ROB, all the niceness
 by KS.)

The BELCH macro 'burps' an entire file, using the /∞F file switching
trick.  When finished, it announces the number of records in the file
before and after BELCHing, and the number of disk tracks thus freed.

Side effects:	A jump is made to the directory page, and the page stack
		will reflect that.  Macros named BEFORE, AFTER, SAVED,
		TRACKS, and SAYER are created (or altered).
⊗↔

αXDEFINE BELCH⊗↔
	α1αPα∞αL⊗↑⊗↑			⊗; Go to directory page, ENDMK line
	αCαβXBREAK 1⊗↔αβ1αβK		⊗; Flush "C" from record number
	αβXBREAK 5⊗↔αβ-αβC		⊗; Flush other junk, move up
	αXREDEFINE BEFORE⊗↔αβK		⊗; Define BEFORE as old total records
	αβXMULTIPLY BEFORE⊗↔		⊗; Flush leading zeros
	αε/∞F⊗↔				⊗;  BURP entire file
	αCαβXBREAK 1⊗↔αβ1αβK		⊗; Flush "C" from record number
	αβXBREAK 5⊗↔αβ-αβC		⊗; Flush other junk, move up
	αXREDEFINE AFTER⊗↔αβK		⊗; Define AFTER as new total records
	αβXMULTIPLY AFTER⊗↔		⊗; Flush leading zeros
	αXSET SAVED←BEFORE⊗↔		⊗; Calculate savings in records
	αXARGUMENT AFTER⊗↔αXSUBTRACT SAVED⊗↔
	αXSET TRACKS←BEFORE⊗↔		⊗; Calculate track savings
	αβ1αβ8αXDIVIDE TRACKS⊗↔
	αXSET TRKAFT←AFTER⊗↔
	αβ1αβ8αXDIVIDE TRKAFT⊗↔
	αXARGUMENT TRKAFT⊗↔αXSUBTRACT TRACKS⊗↔
	αO				⊗; Go back where we was
	αβI				⊗; Make a place to type
	⊗α⊗βXSAY Before: αβZBEFORE⊗↔	⊗; Type "αβXSAY Before:"&BEFORE
		. After: αβZAFTER⊗↔	⊗; Type ". After:"&AFTER
		. Saved recs: αβZSAVED⊗↔	⊗; Type ". Saved recs:"&SAVED
		. (αβZTRACKS⊗↔ tracks)⊗⊗↔	⊗; Type "("&TRACKS&" tracks)⊗↔"
	αAαXREDEFINE SAYER⊗↔		⊗; Now make a macro out of this
	αEαXCANCEL⊗↔			⊗; And cover our tracks
	αZSAYER⊗↔			⊗; Say it all
αβ⊗↓

αxsay  BELCH⊗↔