editor reverse line bet

Kenneth Ng KEN%ORION.BITNET at WISCVM.WISC.EDU
Sat Oct 11 00:39:13 AEST 1986


>P.S. A Challenge to those Other Editor users, I can write a vi macro to
>    reverse the words on a line.. can you?

Hm. I've only spent 15 minutes on this so it isn't perfect, but
for the sake of demonstration that it can be done I have done 3
"macros" on 3 different systems.  Unfortunately one of them I
cannot test since I no longer have an account on that system.
They are:
------------------------------------------------
XEDIT: (Yes that infamous IBM editor)

/* reverse the words on a line, for a Unix-Wizards bet */
'extract/curline'
old_line = curline.3    /* get the contents of current line */
new_line = ""
do while length(old_line) > 0
   /* break "old_line" apart into "word" and "rest" */
   parse value old_line with word rest
   new_line = word || " " || new_line  /* put it back together */
   old_line = rest
   end
'replace' new_line
exit
------------------------------------------------
EIES Interact (The custom editor for the NJIT based computerized
conferencing and communications center)

+own;+ownlu;+rem rev words on a line,for a Unix-Wizard bet
+open1,u,sp;+l a$:=itm(1,&1)
+l b$:=""
+loop
+test len(a$)>0;+exit
+l b$:=sub(a$,1,fnd(' ',a$),0)+b$
+l a$:=sub(a$,fnd(' ',a$)+1,0)
+endloop
+l itm(1,&1):=b$
+ret
------------------------------------------------
Finally, from my student days on an ancient Univac 90-80/4 mainframe
clunker, the system editor EDT(Note: this one is not tested since
I no longer have an active account on it):
@#l1=?
@#s1=#l1
@d#s2
@(loop)on#s1find' '
@#s3=#s1:#i0-#i1
@prefix #s2 with #s3
@delete #s1:#i0-#i1
@goto-(loop)
@create #l1 with #s2
-------------------------------------------------
Now for a little soap box time.  It seems to me that one of the
most powerful features of a text editor is the ability to write
custom programs with a language the editor can understand.  The
three editors mentioned above have such features.  Therefore
practically any needed function can be added easily.  This is the
one feature I find so lacking in VI(1).  The macro facility kinda
has this, but I haven't seen the functionality of a real programming
language in this editor.  What I'd really like to see is an editor
that has the repeat edit facility of vi, combined with the macro
editor capabilities of XEDIT.  Also, I'd like to see an editor
which minimizes screen updates, like WordStar.  Are there any?
Well, that's enough soap box time for me, the altitude is getting
me dizzy.

P.S. A friend of mine wrote an operating system simulator in the
macro language of the last editor.  It included job scheduling,
printer queueing, memory resource allocation, and cpu utilization.
Has anyone done THAT in vi?

Kenneth Ng
NJIT - CCCC; Newark, New Jersey 07102
Bitnet: ken at orion.bitnet (prefered )
Uucp: ihnp4!allegra!bellcore!argus!ken
      psuvax1!cmcl2!caip!andromeda!argus!ken (faster)



More information about the Comp.unix.wizards mailing list