ule praxis
                      random notes for day to day operation

For all the gesticulation and pontificating previously there is little reason
to be using a line editor on a PC.


Delete all but the last 10 logs in a directory:

     >ls -1 *.log > x    - create the list
     >ule x
     .
     >e                  - goto end
     >-10                - back up 10 lines
     >d 9999             - delete the rest of file
     >0                  - go to top of file
     >ca //rm /          - squeeze rm in front of each line
     .
     >sq
     >. ./x              - execute script
     >rm x               - clean up!

--locate, number, and zoom cycle--

For programming or such this is a very common cycle. Use locate to find all 
occurances of a string, say fgets, enter the line # of the appropriate line, 
and print zoom (pz). This shows 10 lines before and after the appropriate
line. From here serious work may commence.

--imbedded tabs--

This can be a problem for any line editor since the display shows blanks when
the file may contain a <TAB> character. ule makes no attempt to deal with
<TAB> characters. If you insist you may even do inserts, replaces, and even
locates and changes entering <TAB> characters. The simplest solution however 
is to expand tabs using the following: (or something like it)
usage: >exptabs [tabsetting(=8)] <infile >outfile

#include<stdio.h>
#
main (int argc, char **argv) {
   int c,p,ts;
   p=1;
   ts=8;
   if (argc==2) {ts=atoi(argv[1]);}
   c=getchar();
   while (c != EOF) {
      switch(c) {
         case EOF : break;
         case '\t' :
            do {
               putchar(' ');
               p=p+1;
               } while( (p % ts) != 1);
          break;
         case '\n' : putchar(c); p=1;   break;
         default   : putchar(c); p=p+1; break;
      }
      c=getchar();
   }
}
 
--using cut and paste--

Obviously there is no cut and paste with a line editor. Well kind of. The idea
is put ule in INPUT mode, make the cut, make the paste, and as long as the cut
has no blank lines (to keep ule from going back to EDIT mode) the operation
should be sussesful. However the screen may look funny. Consider the following
example: note <CR> means enter carriage return

/home/oracle >cat hiworld.c     (WE WILL CUT THE NEXT 4 LINES)----------------
main()
{
   printf("hello world!\n");
}
/home/oracle >ule hw.c

>>>> Holg's ULE (Unix Line Editor) V1.2x experimental!? (12/05/97)
>>>>        64000 Lines Maximum!

>>>>>>>>NEW FILE

>>>>>>>>    FILE :hw.c
>>>>>>>> # Lines :     0

   0E><CR>                      (ule IS PUT INTO INPUT MODE)-----------------
     0I>main()
{
   printf("hello world!\n");     1I>     2I>
}
     3I>     4I><CR>            (DONE! BUT THE SCREEN LOOKS FUNNY, GO EDIT MODE)
   4E>pa
     1.>main()
     2.>{
     3.>   printf("hello world!\n");
     4.>}
4EOF>
     0.>
   0E>                         (ITS OK! YOUR RESULTS MAY VARY)----------------