From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 28-APR-1989 13:07
To:	MRGATE::"ARISIA::EVERHART"
Subj:	MORE/TPU: File 1 of 3

Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Fri, 28 APR 89 07:43:33 PDT
Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Fri, 28 Apr 89 07:33:01 PDT
Received: by ucbvax.Berkeley.EDU (5.61/1.36)
	id AA22886; Fri, 28 Apr 89 07:07:21 -0700
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 28 Apr 89 12:46:13 GMT
From: uflorida!haven!umbc3!rostamia@g.ms.uky.edu  (Rouben Rostamian)
Organization: Univ of Maryland Baltimore County
Subject: MORE/TPU: File 1 of 3
Message-Id: <1959@umbc3.UMBC.EDU>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com


$! ................... Cut between dotted lines and save. ...................
$!...........................................................................
$! VAX/VMS archive file created by VMS_SHARE V06.10 7-FEB-1989.
$!
$! VMS_SHARE was written by James Gray (Gray:OSBUSouth@Xerox.COM) from
$! VMS_SHAR by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au).
$!
$! To unpack, simply save, concatinate all parts into one file and
$! execute (@) that file.
$!
$! This archive was created by user ROSTAMIAN
$! on 28-APR-1989 08:40:22.19.
$!
$! ATTENTION: To keep each article below 31 blocks (15872 bytes), this
$!            program has been transmitted in 3 parts.  You should
$!            concatenate ALL parts to ONE file and execute (@) that file.
$!
$! It contains the following 7 files:
$!        AAREADME.1ST
$!        AAREADME.NEXT
$!        MANIFEST.TXT
$!        MORE.COM
$!        MORE.HELP
$!        MORE.TPU
$!        MORE_EDIT.COM
$!
$!============================================================================
$ SET SYMBOL/SCOPE=( NOLOCAL, NOGLOBAL )
$ VERSION = F$GETSYI( "VERSION" )
$ IF VERSION .GES "V4.4" THEN GOTO VERSION_OK
$ WRITE SYS$OUTPUT "You are running VMS ''VERSION'; ", -
    "VMS_SHARE V06.10 7-FEB-1989 requires VMS V4.4 or higher."
$ EXIT 44 ! SS$_ABORT
$VERSION_OK:
$ GOTO START
$!
$UNPACK_FILE:
$ WRITE SYS$OUTPUT "Creating ''FILE_IS'"
$ DEFINE/USER_MODE SYS$OUTPUT NL:
$ EDIT/TPU/COMMAND=SYS$INPUT/NODISPLAY/OUTPUT='FILE_IS'/NOSECTION -
    VMS_SHARE_DUMMY.DUMMY
b_part := CREATE_BUFFER( "{Part}", GET_INFO( COMMAND_LINE, "file_name" ) )
; s_file_spec := GET_INFO( COMMAND_LINE, "output_file" ); SET( OUTPUT_FILE
, b_part, s_file_spec ); b_errors := CREATE_BUFFER( "{Errors}" ); i_errors 
:= 0; pat_beg_1 := ANCHOR & "-+-+-+ Beginning"; pat_beg_2 := LINE_BEGIN 
& "+-+-+-+ Beginning"; pat_end := ANCHOR & "+-+-+-+-+ End"; POSITION
( BEGINNING_OF( b_part ) ); LOOP EXITIF SEARCH( SPAN( ' ' )@r_trail 
& LINE_END, FORWARD) = 0; POSITION( r_trail ); ERASE( r_trail ); ENDLOOP
; POSITION( BEGINNING_OF( b_part ) ); i_append_line := 0; LOOP EXITIF MARK
( NONE ) = END_OF( b_part ); s_x := ERASE_CHARACTER( 1 )
; IF s_x = '+' THEN r_skip := SEARCH( pat_beg_1, FORWARD, EXACT ); IF r_skip 
<> 0 THEN s_x := ''; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ERASE_LINE; ENDIF
; ENDIF; IF s_x = '-' THEN r_skip := SEARCH( pat_end, FORWARD, EXACT )
; IF r_skip <> 0 THEN s_x := ''; MOVE_HORIZONTAL( -CURRENT_OFFSET ); m_skip 
:= MARK( NONE ); r_skip := SEARCH( pat_beg_2, FORWARD, EXACT ); IF r_skip 
<> 0 THEN POSITION( END_OF( r_skip ) ); MOVE_HORIZONTAL( -CURRENT_OFFSET )
; MOVE_VERTICAL( 1 ); MOVE_HORIZONTAL( -1 ); ELSE POSITION( END_OF( b_part ) 
); ENDIF; ERASE( CREATE_RANGE( m_skip, MARK( NONE ), NONE ) ); ENDIF; ENDIF
; IF s_x = 'V' THEN s_x := ''; IF i_append_line <> 0 THEN APPEND_LINE
; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF; i_append_line := 1
; MOVE_VERTICAL( 1 ); ENDIF; IF s_x = 'X' THEN s_x := ''; IF i_append_line 
<> 0 THEN APPEND_LINE; MOVE_HORIZONTAL( -CURRENT_OFFSET ); ENDIF
; i_append_line := 0; MOVE_VERTICAL( 1 ); ENDIF; IF s_x <> '' THEN i_errors 
:= i_errors + 1; s_text := CURRENT_LINE; POSITION( b_errors ); COPY_TEXT
( "The following line could not be unpacked properly:" ); SPLIT_LINE
; COPY_TEXT( s_x ); COPY_TEXT( s_text ); POSITION( b_part ); MOVE_VERTICAL
( 1 ); ENDIF; ENDLOOP; POSITION( BEGINNING_OF( b_part ) ); LOOP r_x := SEARCH
( "`", FORWARD, EXACT ); EXITIF r_x = 0; POSITION( r_x ); ERASE_CHARACTER( 1 
); COPY_TEXT( ASCII( INT( ERASE_CHARACTER( 3 ) ) ) ); ENDLOOP
; IF i_errors = 0 THEN SET( NO_WRITE, b_errors, ON ); ELSE POSITION
( BEGINNING_OF( b_errors ) ); COPY_TEXT( FAO
( "The following !UL errors were detected while unpacking !AS", i_errors
, s_file_spec ) ); SPLIT_LINE; SET( OUTPUT_FILE, b_errors, "SYS$COMMAND" )
; ENDIF; EXIT; 
$ DELETE VMS_SHARE_DUMMY.DUMMY;*
$ CHECKSUM 'FILE_IS
$ WRITE SYS$OUTPUT " CHECKSUM ", -
  F$ELEMENT( CHECKSUM_IS .EQ. CHECKSUM$CHECKSUM, ",", "failed!!,passed." )
$ RETURN
$!
$START: 
$ FILE_IS = "AAREADME.1ST"
$ CHECKSUM_IS = 1211387645
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
XThis is an implementation of UNIX's MORE utility written in VMS's TPU.
XThe emulation is not entirely faithful to the original.  There are a`032
Xfew missing features and a few extras.  Read MORE.HELP for a complete
Xdescription of the supported functions.  [Press 'h' from within MORE
Xto display the MORE.HELP file anytime.]
X
XThe most serious shortcoming, in my opinion, is the inability of the`032
Xcurrent version to position the text properly upon entering the edit`032
Xmode; the edit mode begins at the top of the file.  I know how to
Xfix this problem but I don't think it's worth the bother.
X
XIn the (unlikely?) event that you flip-flop several times between the`032
Xdefault MORE mode and the edit mode, you may exhaust your subprocess
Xquota;  each edit mode is entered by creating a subprocess which is not
Xdeleted until you exit MORE.
X
XRouben Rostamian
XDepartment of Mathematics                       e-mail:
XUniversity of Maryland Baltimore County         rostamian@umbc2.bitnet
XCatonsville, MD 21228                           rostamia@umbc3.umbc.edu
$ GOSUB UNPACK_FILE

$ FILE_IS = "AAREADME.NEXT"
$ CHECKSUM_IS = 1114930158
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
XInstructions for compiling and running the MORE utility
X
X1. Create the TPU section file for MORE: `032
X   edit/tpu/nosection/command=more.tpu
X   This will create a MORE$SECTION.TPU$SECTION file in the current directory.
X
X2. Define the logical name MORE$DIR to point to the directory where you
X   place MORE files:
V   define MORE$DIR this_disk:[directory.subdirectories] ! put this in login.c
Xom`032
X
X3. Define the symbol MORE
X   more :== @MORE$DIR:MORE.COM   ! put this in login.com`032
X
XTo view a file, do`032
X   more <filespec>
Xwhere <filespec> may contain the usual VMS wildcards.
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "MANIFEST.TXT"
$ CHECKSUM_IS = 1243167606
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
XMORE/TPU
XFiles included in this shipment:
X
XAAREADME.1ST         Introduction
XAAREADME.NEXT        Instructions for setting up MORE
XMANIFEST.TXT         This file
XMORE.COM             DCL interface to MORE
XMORE.HELP            On-line help`032
XMORE.TPU             TPU routines for MORE
XMORE_EIDT.COM        Interface between MORE and EVE
$ GOSUB UNPACK_FILE

$ FILE_IS = "MORE.COM"
$ CHECKSUM_IS = 288838717
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X$! Startup command procedure for MORE.  Turns cursor off then starts MORE.
X$!
X$ set noon
X$ esc[0,8] = 27
X$ csi := "''esc'["
X$ cursor_off := "''csi'?25l"
X$ cursor_on := "''csi'?25h"
X$!
X$ on control_y then goto end
X$!
X$ if p1 .eqs. "" then inquire p1 "_File"
X$ if p1 .eqs. "" then exit
X$!
X$ file =  f$search(p1)`032
X$ if file .eqs. ""`032
X$   then
X$     write sys$output "%MORE-W-SEARCHFAIL, error searching for file ''p1';"
X$     write sys$output "_MORE-E-FNF, file not found"
X$     exit
X$ endif
X$!
X$!
X$ write sys$output cursor_off
X$ define/user sys$input sys$command`032
X$ edit/tpu/section=faculty:[rostamian.more]more$section  'p1'
X$ end: write sys$output cursor_on
X$ exit
$ GOSUB UNPACK_FILE

$ FILE_IS = "MORE.HELP"
$ CHECKSUM_IS = 1885172441
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X
X    [ Most commands may optionally be preceded by an integer argument k. ]
X    [ Defaults are shown in brackets.  Star (*) indicates that argument  ]
X    [ becomes the new default.                                           ]
X
X
X                         ---- Scrolling Commands ----
X
X     <space bar>  display next k lines of text  [one screenful]
X     z            display next k lines of text  [one screenful]*
X     <return>     display next k lines of text  [1]*
X     d            display next k lines of text  [half a screenful]*
X     u            display previous k lines of text  [half a screenful]*
X     f            skip forward k screenfuls of text [1]
X     b            skip backward k screenfuls of text [1]
X     g            go to line k [<last line>]
X
X
X                          ---- Search Commands ----
X
X     [Note: Search is case sensitive if "expression" contains any ]
X     [      uppercase letters.  Otherwise it is case-insensitive. ]
X
X     /expression  search forward for "expression"
X     ?expression  search backward for "expression"
X     n            repeat previous search in forward direction
X     p            repeat previous search in reverse direction
X     '            go to place where previous search started
X
X
X                       ---- File Related Commands ----
X
X     =            toggle status line and display file information
X     N            get the next file
X     P            get the previous file
X     G            get the n-th file (argument 'n' required)
X     L            list current files
X
X
X                          ---- Editor Commands ----
X
X     v      start up the EVE editor.  Will return to MORE after edit ends
X     V      start up the EVE editor.  Will not return to MORE after edit ends
X
X
X                           ---- Other Commands ----
X
X     q            exit from more
X     h            give this help screen
X     .  (dot)     repeat previous command (except search commands)
X
$ GOSUB UNPACK_FILE

$ FILE_IS = "MORE.TPU"
$ CHECKSUM_IS = 1648396955
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X! MORE.TPU
X! A version of the UNIX more utility written in TPU for VMS
X!
X! Rouben Rostamian, Jan. 3, 1989.
X! Department of Mathematics                      e-mail:
X! University of Maryland Baltimore County        rostamian@umbc2.bitnet
X! Catonsville, MD 21228                          rostamia@umbc3.umbc.edu
X
X
XPROCEDURE tpu$init_procedure
X
X  set (informational, on);
X  set (success, on);
X  set (facility_name, "TPU_MORE");
X  more$screen_rows := get_info (screen, "visible_length");
X  more$main_window_rows := more$screen_rows - 1;
X
X  more$file := create_array (10, 1);         ! Array of dir+filenames
X  more$short_file := create_array (10, 1);   ! Array of filenames
X  more$buffer := create_array (10, 1);       ! Array of buffers for files
X
X! Create a buffer and a window for messages
X  message_buffer := create_buffer ("Message Buffer");
X  set (no_write, message_buffer);
X  set (system, message_buffer);
X  set (EOB_TEXT, message_buffer, "");
X  message_window := create_window (more$screen_rows, 1, OFF);
X  map (message_window, message_buffer);
X
X! Create an area on the screen for prompts
X  set (prompt_area, more$screen_rows, 1, none);
X
X! Create the main window for more:
X  main_window := create_window (1, more$main_window_rows, OFF);
X
X! Create a list of buffers:
X  more$create_list_buffer;
X
X  set (informational, off);
X  set (success, off);
X  SET (VIDEO, message_window, reverse);
X  message ('');
X
X! Put the current character position in the first buffer and get file
X  more$current_file_number := 1;
X  main_buffer := more$buffer`1231`125;
X  map ( main_window, main_buffer);
X  position(main_buffer);
X  more$top_line_number := 1;
X  more$lines_in_buffer := get_info (current_buffer, 'RECORD_COUNT');
V  more$show_long_status_line := TRUE;  ! Will show a long status line initial
Xly
X  more$show_line_number;
X  update(main_window);
X
X  MORE;
X  QUIT;
XENDPROCEDURE;
X
XPROCEDURE more$create_list_buffer
XLOCAL  priv, no_priv, priv_str, file_spec, count, parameter;
Xon_error
X  if error = tpu$_openin then
X    priv_str := no_priv;
X  endif;
Xendon_error;
X  `032
Xno_priv := '[No Priv]';         !  These two string must have`032
Xpriv    := '         ';         !  equal lengths
X
X! Create a buffer for listing all files
X  list_buffer := create_buffer ("List Buffer");
X  set (no_write, list_buffer);
X  set (system, list_buffer);
X  set (EOB_TEXT, list_buffer, "[End of List Buffer]");
X
X
X! Create buffers for input files
Xfile_spec := file_search ('');  ! Clear search context
Xcount := 0;
Xparameter := get_info (command_line, "file_name");
Xposition (list_buffer);
Xcopy_text ( '                            List of Current Files');
Xmove_vertical (1);
Xcopy_text ('');
Xmove_vertical (1);
Xpriv_str := priv;
Xloop
X  file_spec := file_search (parameter);
X  exitif file_spec = "";
X  count := count + 1;
V  more$file`123count`125 := file_parse (file_spec);   ! device:[dir]name.ext;
Xver
X  more$short_file`123count`125 := file_parse (file_spec, "", "", name)
X                         + file_parse (file_spec, "", "", type)
X                         + file_parse (file_spec, "", "", version);
X  more$buffer`123count`125   := create_buffer (str(count), file_spec);
X
V  copy_text ( fao ('!AS  !SL.  !AS', priv_str, count, more$short_file`123coun
Xt`125) );
X
X  if priv_str = no_priv then
X    position (more$buffer`123count`125);
X    copy_text ('');
X    move_vertical (1);
V    copy_text ('                 [*** No privilege for opening this file ***]
X');
X    move_vertical (1);
X    copy_text ('');
X    move_vertical (1);
X    priv_str := priv;
X    position (list_buffer);
X  endif;
X
X  move_vertical (1);
X  set (no_write, more$buffer`123count`125);
X  set (EOB_TEXT, more$buffer`123count`125, "[End of file]");
Xendloop;
Xcopy_text ('');
Xmove_vertical (1);
Xposition (beginning_of(list_buffer));
Xmore$total_files := count;
XENDPROCEDURE;
X
XPROCEDURE MORE
XLOCAL ch;
V! ---------------------------------------------------------------------------
X-
X! Global variables:
XTRUE := 1;
XFALSE := 0;
Xmore$repeat_search := FALSE;
Xmore$numeric_mode := FALSE;
Xmore$number := 0;
Xmore$pagesize :=  more$main_window_rows - 1;
Xmore$d_scrollamount := more$pagesize / 2;
Xmore$cr_scrollamount := 1;
Xmore$lines_in_buffer := get_info (current_buffer, 'RECORD_COUNT');
Xmore$top_line_number := 1;
Xmore$saved_command := "";
Xmore$saved_string := "";
Xmore$saved_position := beginning_of (current_buffer);
V! ---------------------------------------------------------------------------
X-
X
XSET (SCROLLING, main_window, on, 0, more$main_window_rows, 0);
X
XLOOP
X
X  ch := read_char;
X  exitif ch = "q";
X
X  CASE ch from "0" to "9"
X    [INRANGE]  : more$numeric_mode := TRUE;
X                 more$number := 10 * more$number + INT(ch);
X    [OUTRANGE] : if ch = ASCII(13) then more$cr_scroll;
X                 else if ch = "g" then more$goto_line;
X                 else if ch = "d" then more$d_scroll;
X                 else if ch = "u" then more$u_scroll;
X                 else if ch = " " then more$space_scroll;
X                 else if ch = "z" then more$z_scroll;
X                 else if ch = "b" then more$back_scroll;
X                 else if ch = "f" then more$forward_scroll;
X                 else if ch = "." then more$repeat_command;
X                 else if ch = "'" then more$goto_previous_mark;
X                 else if ch = "=" then more$show_line_number;
X                 else if ch = "h" then more$give_help;
X                 else if ch = "n" then more$search_mode := forward;`032
X                                       more$search_prompt := "/";`032
X                                       more$new_search := FALSE;
-+-+-+-+-+ End of part 1 +-+-+-+-+-
-- 
Rouben Rostamian
Department of Mathematics                      e-mail:
University of Maryland Baltimore Counnty       Rostamian@umbc2.bitnet
Baltimore, MD 21228                            rostamia@umbc3.umbc.edu

