perm filename EINIT.CMD[1,3]3 blob sn#350112 filedate 1978-04-19 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00010 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 - Reverse a line, reverse an FMUNGE character ↔
C00008 00005	αβxcomment REF - #bloat gives you # number of empty records for this page 
C00010 00006	αβxcomment REF - word transposition. ↔
C00011 00007	αβxcomment REF - counters.  For example, to number the lines of a page.
C00013 00008	αβxcomment REF - FIND. finds the current search string in a set of files.
C00015 00009	αβxcomment REF - Saving a readonly page    SAVE.
C00016 00010	αβxcomment LIS - counting macros
C00022 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⊗↔αβ⊗↓

αβxcomment REF - Reverse a line, reverse an FMUNGE character ⊗↔

αβxcomment If you call the macro REVERSe with an argument of the size of the
line involved, it will reverse that line.
⊗↔

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

αβxcomment point the arrow at the line to be reversed ⊗↔
αXDEFINE REVERS⊗↔
αβ1αβxbreak 1⊗↔αβ#αβaαβ#αβzup⊗↔αβ#αβuαβ#αβxjoin⊗↔αβ1αβxabort⊗↔
αβ⊗↓

αβxcomment So, to reverse an fmunge character 16 wide, 25 long, call, 25 times: 
(note the 16 in the CHRREV macro) ⊗↔

αXDEFINE CHRREV⊗↔
αβ1αβ6αβzreverse⊗↔⊗↔
αβ⊗↓
αβxcomment REF - #bloat gives you # number of empty records for this page 

This macro saves your file! (it causes the page(s) in core to be written on disk) ⊗↔

αXDEFINE BLOAT⊗↔
αβ0αβxautoburp⊗↔
αβxcomment turn off autoburping⊗↔
αβ∞αβlαβxm⊗↔
αβxcomment move to the end of the page and start a new page⊗↔
αβ#αβzrecord⊗↔
αβxcomment fill the page with # records of garbage⊗↔
αβ-αβpαβ∞αβlαβxdel⊗↔
αβxcomment go to the bottom of the previous page, and delete the page mark⊗↔
αβ.αβ9αβ9αβ9αβ9αβdαβ.αβ1αβ7αβxauto⊗↔
αβxcomment save the world, delete the trash, save the world.  Reset autoburp⊗↔
αβ⊗↓

αXDEFINE RECORD⊗↔
αβz62x⊗↔αβ-αβcαβcαβcαβcαβcαβcαβcαβcαβcαβeαβ⊗↓

αXDEFINE 62X⊗↔
αβ6αβ2x⊗↔αβ⊗↓

αβ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↔
αβ⊗↓
αβxcomment REF - counters.  For example, to number the lines of a page.
The numbers from 1 to 46.  When you need
to either 1) Number a group of lines or 2) GENSYM some symbols,
make a copy of this line, and, in your macro, peel numbers off from the
front.

1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,

⊗↔

αβxcomment Fills an attach buffer with the numbers 1 through 45 ⊗↔
αβxdefine nums⊗↔
αβ1αβ⊗↔
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,α⊗↔
αa
αβ⊗↓

αβxcomment Point the arrow at the first line to be numbered, and call this
macro with the number of lines to be numbered as its argument⊗↔
αβxdefine number⊗↔
αznums⊗↔
αβ#αβznumlin⊗↔
αβkαβxabort⊗↔
αβ⊗↓

αβxdefine numlin⊗↔
αβeαs,α β⊗↔
αβxcomment drop the attach buffer, and peel the first number off it⊗↔
αβ-αβa⊗↔αβeαs,⊗=α⊗=αdα⊗↔
αβxcomment affix it to the next line⊗↔
αβ-αβa⊗↔
αβxcomment and proceed.  If something other than a tab is desired between
the numbers and the lines, replace the first ⊗= with <control>d<string>.
If only every nth line is to be numbered, insert n-1 <cr> here.     ⊗↔
αβ⊗↓
αβxcomment REF - FIND. finds the current search string in a set of files.
Fill in your own file names for FOO.N below (in your own copy of the macro, please)
and get the extended "find" command to be set to your string.  Then execute
the macro FIND.  The first time it finds something, it will stop.  To find the
other occurences in that file, use *.  To go on to the next file, use
xRESUME. ⊗↔

αβxdefine f1⊗↔
αβεfoo.1[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine f2⊗↔
αβεfoo.2[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine f3⊗↔
αβεfoo.3[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine f4⊗↔
αβεfoo.4[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine f5⊗↔
αβεfoo.5[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine g1⊗↔
αβεfoo.6[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine g2⊗↔
αβεfoo.7[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine g3⊗↔
αβεfoo.8[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine g4⊗↔
αβεfoo.9[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine g5⊗↔
αβεfoo.10[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓
αβxdefine g6⊗↔
αβεfoo.11[1,baz]⊗↔αβvαβ*αβxabort⊗↔αβ⊗↓

αβxdefine find⊗↔
αβx stopone⊗↔
αβz f1⊗↔
αβz f2⊗↔
αβz f3⊗↔
αβz f4⊗↔
αβz f5⊗↔
αβz g1⊗↔
αβz g2⊗↔
αβz g3⊗↔
αβz g4⊗↔
αβz g5⊗↔
αβz g6⊗↔
αβ⊗↓
αβ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⊗↔
αβ⊗↓
αβxcomment LIS - counting macros

The macro inc is the basic counting macro.  It assumes that the arrow
is at a line containing only a number, represented as a string of decimal
digits.  Inc adds one to this number, and leaves the result on the line
in place of the old number.  Inc can handle numbers up to about 100 digits
long, and could be fixed to handle numbers as long as will fit in the line
editor.

Inc operates by separating the last digit, and turning it into a macro call
of the form incnx where x is the digit.  This macro call is then executed.
The incnx macros all replace the given digit with its successor, and incn9
also causes a carry, by repeating the process of turning the last digit into
a macro call.  There are also some things to make inc properly extend numbers
(carry off the left-most digit), and the macro close which concatenates
the number back together on one line again.

The macros initn, add1n, and nextn use the macro n as a register - it
holds an integer represented as a string of decimal digits.  Initn sets n to
0.  Add1n increments n by 1.  Nextn increments n by 1 and inserts a new
line where the arrow is pointing, with the new value of n as its contents.
(All three of these do a ctrl-cr before anything else, to exit the line
editor and line insert mode.)

BEWARE! INC changes the value of the STOPONE/STOPALL/STOPZERO switch
(leaving it set to STOPALL).  Also, a mark at the number line will be lost.

⊗↔
αXDEFINE inc⊗↔
	β α⊗↔		αxcomment  insert a leading space, to allow for carry
				    off left end of number  ⊗↔
	αβm⊗↔β⊗↔αu	αxcomment  mark place and put in trailing blank line,
				    both for use by CLOSE  ⊗↔
	αz inccry ⊗↔	αxcomment  increment: make last digit it into an
				    INCNx macro call, and ...  ⊗↔
	α1α0α0αzincdo⊗↔	αxcomment  execute INCNx macro(s)  ⊗↔
	αz inca ⊗↔	αxcomment  deletes leading space if still there,
			    else deletes extra blank line that is there  ⊗↔
	αzclose⊗↔	αxcomment  return digits to one line  ⊗↔
αβ⊗↓

αxDEFINE inccry⊗↔	αxcomment  make last digit of previous line into an
				    INCNx macro call  ⊗↔
	αUα⊗Tα⊗↑β⊗↔
	αi⊗αzincnα ⊗⊗↔α⊗↔
αβ⊗↓

αxDEFINE incdo⊗↔	αxcomment  execute present line as a macro  ⊗↔
	α1αxredefine incdo1⊗↔αzincdo1⊗↔
αβ⊗↓

	αxcomment  The INCNx macros - each turns the present line into the
	single digit x+1, where <space>+1 is 1 and 9+1 is 0.  Then all but
	INCN9 abort back to INC, while INCN9 causes a carry by turning the
	next digit into an INCNx macro call, which is then executed by the
	repeated INCDO  ⊗↔
αXDEFINE incn ⊗↔1αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn0⊗↔1αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn1⊗↔2αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn2⊗↔3αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn3⊗↔4αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn4⊗↔5αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn5⊗↔6αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn6⊗↔7αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn7⊗↔8αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn8⊗↔9αk⊗↔α⊗↔α3αxabort⊗↔αβ⊗↓
αXDEFINE incn9⊗↔0αk⊗↔αzinccry⊗↔αβ⊗↓

αxDEFINE inca⊗↔		αxcomment  kill extra blank or empty line
				    introduced by carrying from last digit  ⊗↔
	αuαdα⊗↔
αβ⊗↓

αXDEFINE CLOSE⊗↔	αxcomment  back up to previous mark, and concatenate
				    all lines through next empty line  ⊗↔
αx stopone ⊗↔⊗↔α-αmα1α0α0αz cls1 ⊗↔αβdαuα-αβmαx stopall ⊗↔αβ⊗↓

αXDEFINE CLS1⊗↔
⊗↔α0αx nonempty ⊗↔αuα⊗=αdαβ⊗↓

αXDEFINE nextn⊗↔
	α⊗↔αβ⊗↔αz n ⊗↔α⊗↔	αxcomment  put n on a new line ⊗↔
	αz inc ⊗↔		αxcomment  increment it ⊗↔
	α1αxredef n ⊗↔		αxcomment  save the new value ⊗↔
αβ⊗↓

αXDEFINE add1n⊗↔
	αz nextn ⊗↔		αxcomment  get new value ⊗↔
	αβd			αxcomment  delete it from the file ⊗↔
αβ⊗↓

αXDEFINE initn⊗↔
	α⊗↔αβ⊗↔0α⊗↔
	α1αxredef n ⊗↔
	αβd
αβ⊗↓