From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 12-DEC-1989 12:13
To:	MRGATE::"ARISIA::EVERHART"
Subj:	Retrieve, part 5 of 5

Received: From NAC.NO by GIZMO.SRI.COM with TCP; Tue, 12 DEC 89 07:28:21 PDT
Received: from runix.runit.sintef.no by nac.no (5.61++/1.15) with SMTP 
	id AA14340; Tue, 12 Dec 89 16:26:13 +0100
Received: by runix.runit.sintef.no (norunix.EARN) (1.2/7.8)
	id AA19874;  Tue, 12 Dec 89 16:26:54 +0100
Date: 12 Dec 89 16:25 +0100
From: Jo Torsmyr <j_torsmyr%avh.unit.uninett@nac.no>
To: info-vax@kl.sri.com
Message-Id: <231*j_torsmyr@avh.unit.uninett>
Subject: Retrieve, part 5 of 5

+-+-+-+ Beginning of part 5 +-+-+-+
X`009  output device.
X
X      `032
X      FORMAL PARAMETERS:`032
X      `032
X`009  NONE
X      `032
X      IMPLICIT INPUTS:
X      `032
X`009  LogEndPointer and RecallArray.
X      `032
X      IMPLICIT OUTPUTS:
X      `032
X`009  NONE
X      `032
X      ROUTINE VALUE:
X      `032
X`009  NONE
X      `032
X      SIDE EFFECTS:
X      `032
X`009  NONE
X      `125
X  `032
X    VAR
X      (* Local bufferpointer to step through the recallbuffer *)
X      LogP`009`009: BufferInt ;
X      CmdPrefix,`009`009`009(* Contains the command number *)
X      CmdStr`009`009: VarCmdType ;`009(* Command string to be written *)
X      NumOfCmds,`009`009`009(* Number of commands displayed *)
X      StartNr, EndNr`009: $UBYTE ;`009(* Start & End command numbers *)
X      IO_Channel`009: $UWORD ;`009(* Terminal channel *)
X
X
X  PROCEDURE WriteCmd (CmdString : VarCmdType) ;
X  `032
X      `123
X      FUNCTIONAL DESCRIPTION:`032
X      `032
X`009  WriteCmd writes a command to the current output device, using
X`009  standard pascal write! (the only standard pascal in this program?)
X`009  Sorry, but now I'm using $QioW, so nothing is standard anymore!
X      `032
X      FORMAL PARAMETERS:`032
X      `032
X`009  CmdString - the command string to be written.
X
X      IMPLICIT INPUTS:
X      `032
X`009  IO_Channel.
X      `032
X      IMPLICIT OUTPUTS:
X      `032
X`009  NONE
X      `032
X      ROUTINE VALUE:
X      `032
X`009  NONE
X      `032
X      SIDE EFFECTS:
X      `032
X`009  NONE
X      `125
X  `032
X    BEGIN
X      $QioW (Chan  := IO_Channel,`009(* Channel *)
X`009     Func  := IO$_WriteVBlk,`009(* Function *)
X`009     P1    := CmdStr.Body,`009(* Write string *)
X`009     P2    := CmdStr.Length,`009(* Write length *)
X`009     P4    := 13) ;`009`009(* CR control *)
X  END (* of PROCEDURE WriteCmd *) ;
X
X
X  FUNCTION CheckValues (VAR St, En : $UBYTE) : BOOLEAN ;
X  `032
X      `123
X      FUNCTIONAL DESCRIPTION:`032
X      `032
X`009  ChechValues check whether the START value is not greater than the
X`009  END value.
X
X      `032
X      FORMAL PARAMETERS:`032
X      `032
X`009  St - The returned startvalue.
X`009  En - The returned endvalue.
X      `032
X      IMPLICIT INPUTS:
X      `032
X`009  NONE
X      `032
X      IMPLICIT OUTPUTS:
X      `032
X`009  NONE
X      `032
X      ROUTINE VALUE:
X      `032
X`009  Returns TRUE if END value is greater than or equal to START value,
X`009  FALSE otherwise.
X      `032
X      SIDE EFFECTS:
X      `032
X`009  NONE
X      `125
X  `032
X    VAR
X      Str : VarCmdType ;
X    BEGIN
X      (* Get start value *)
X      IF (Cli$Present (Cli$_List_Start) = Cli$_Present) THEN
X`009 BEGIN
X`009   Cli$Get_Value (Cli$_List_Start, Str) ;
X`009   ReadV (Str, St, Error := Continue)
X`009 END (* of IF *)
X      ELSE
X`009 St  := LowByteValue + 1 ;
X
X      (* Get end value *)
X      IF (Cli$Present (Cli$_List_End) = Cli$_Present) THEN
X`009 BEGIN
X`009   Cli$Get_Value (Cli$_List_End, Str) ;
X`009   ReadV (Str, En, Error := Continue) ;
X`009 END (* of IF *)
X      ELSE
X`009 En  := HighByteValue ;
X
X      CheckValues := En >= St ;
X  END (* of FUNCTION CheckValues *) ;
X
X
X    BEGIN (* of PROCEDURE ListCmds *)
X      LogP := LogEndPointer ;
V      IF NOT (RecallArray[Inc (LogP, -1)] = Null) THEN (* => Buffer not empty
X *)
X`009 BEGIN
X`009   IF CheckValues (StartNr, EndNr) THEN (* => Legal START/END values *)
X`009      BEGIN
X`009`009(* Skip the number of commands specified by StartNr *)
X`009`009SkipCommands (LogP, NumOfCmds, StartNr) ;
X`009`009NumOfCmds := StartNr ;
X
X`009`009$Assign (Terminal, IO_Channel) ;   (* Assign terminal channel *)
X`009`009(* Go to End!!! *)
X`009`009REPEAT
X`009`009  GetPrevCommand (CmdStr, LogP) ;
X`009`009  WriteV (CmdPrefix, StartNr:2, ' ') ;
X`009`009  Str$Prefix (CmdStr, CmdPrefix) ;
X`009`009  WriteCmd (CmdPrefix) ;
X`009`009  StartNr := StartNr + 1 ;
X`009`009UNTIL (* Make LogP point to the trailing length byte *)
X`009`009      (RecallArray[Inc (LogP, -1)] = Null) OR
X`009`009      (StartNr > EndNr) ;
X
X`009`009$DAssgn (IO_Channel) ;`009
X
X`009`009IF Log THEN
X`009`009   BEGIN
X`009`009     NumOfCmds := StartNr - NumOfCmds ;
X`009`009     Lib$Signal (RETR_TotOfCmds, 1, NumOfCmds) ;
X`009`009   END (* of IF *)
X`009      END (* of IF *)
X`009   ELSE Lib$Signal (RETR_IllValRan) ;
X`009 END (* of IF *)
X      ELSE
X`009 Lib$Signal (RETR_NoComFou) ;
X  END (* of PROCEDURE ListCmds *) ;
X
X`032
X  PROCEDURE FlushBuffer ;
X  `032
X      `123
X      FUNCTIONAL DESCRIPTION:`032
X      `032
X`009  FlushBuffer runs in excutive mode. Flushes the recallbuffer and
X`009  resets the recallbufferpointer.
X
X      `032
X      FORMAL PARAMETERS:`032
X      `032
X`009  NONE
X      `032
X      IMPLICIT INPUTS:
X      `032
X`009  NONE
X      `032
X      IMPLICIT OUTPUTS:
X      `032
X`009  RecallArray and PhysEndPointer.
X      `032
X      ROUTINE VALUE:
X      `032
X`009  NONE
X      `032
X      SIDE EFFECTS:
X      `032
X      `125
X  `032
X    BEGIN
X      RecallArray`009:= Zero ;
X      PhysEndPointer`009:= PhysStartAddr ;
X  END (* of PROCEDURE FlushBuffer *) ;
X
X
X  PROCEDURE FlushCmds ;
X  `032
X      `123
X      FUNCTIONAL DESCRIPTION:`032
X      `032
X`009  FlushCmds flushes the recallbuffer, zeroing out all bytes, and
X`009  setting the pointer to the startaddress of the buffer. The routine
X`009  FlushBuffer is called to do this in executive mode.
X
X      `032
X      FORMAL PARAMETERS:`032
X      `032
X`009  NONE
X      `032
X      IMPLICIT INPUTS:
X      `032
X`009  NONE
X      `032
X      IMPLICIT OUTPUTS:
X      `032
X`009  NONE
X      `032
X      ROUTINE VALUE:
X      `032
X`009  NONE
X      `032
X      SIDE EFFECTS:
X      `032
X`009  NONE
X      `125
X  `032
X    BEGIN
X      $CmExec (%IMMED FlushBuffer) ;
X      IF Log THEN Lib$Signal (RETR_RecBufFlu) ;
X  END (* of PROCEDURE FlushCmds *) ;
X
X
V  (* The main program checks for qualifiers or parameter and then calls the *
X)
X  (* appropriate routine. *)
X
X  BEGIN (* of PROGRAM Retrieve *)
X    All`009`009    := (Cli$Present (Cli$_All)`009    = Cli$_Present) ;
X    Erase`009    := (Cli$Present (Cli$_Erase)    = Cli$_Present) ;
X    Flush`009    := (Cli$Present (Cli$_Flush)    = Cli$_Present) ;
X    List`009    := (Cli$Present (Cli$_List)`009    = Cli$_Present) ;
X    Log`009`009    := (Cli$Present (Cli$_Log)`009    = Cli$_Present) ;
X    Restore`009    := (Cli$Present (Cli$_Restore)  = Cli$_Present) ;
X    Save`009    := (Cli$Present (Cli$_Save)`009    = Cli$_Present) ;
X    Verify`009    := (Cli$Present (Cli$_Verify)   = Cli$_Present) ;
X
X    (* Check parameter 1 (command or number) *)
X    (* If it's present then ok, but if it isn't, we must check whether a *)
X    (* qualifier is present, if not, parameter 1 is present by default *)
X
X    IF (Cli$Present (Cli$_Par1) = Cli$_Present) OR
X       ((Cli$Present (Cli$_Par1) = Cli$_Defaulted) AND
X`009NOT (All OR Erase OR Flush OR List OR Restore OR Save OR Verify)) THEN
X       RecallCmd
X    ELSE (* => Some qualifier is present... *)
X       BEGIN
X`009 IF Restore`009    THEN LoadCmds ;
X`009 IF All OR List`009    THEN ListCmds ;
X`009 IF Save`009    THEN SaveCmds ;
X`009 IF Erase OR Flush  THEN FlushCmds ;
X`009 IF Verify`009    THEN
X`009    Lib$Signal (RETR_RetrVer, 1, %STDESCR (VersionStr)) ;
X       END (* of ELSE *) ;
X
XEND (* of PROGRAM Retrieve *) .
$ GOSUB UNPACK_FILE

$ FILE_IS = "RETRIEVE_RTL_ROUTINES.PSE"
$ CHECKSUM_IS = 941121941
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X[ENVIRONMENT ('Retrieve_RTL_routines')]
X
X`123
X  Denne modulen har jeg rotet sammen fra personlig definerte RTL filer.
X  De stemmer ikke med tilsvarende filer paa SYS$LIBRARY, men de virker!
X`125
X
XMODULE Retrieve_RTL_routines ;
X
X[ASYNCHRONOUS, EXTERNAL]
XFUNCTION str$case_blind_compare (
X  first_source_string`009: VARYING [A] OF CHAR ;
X  second_source_string`009: VARYING [B] OF CHAR) : INTEGER ; EXTERNAL ;
X
X
X[ASYNCHRONOUS, EXTERNAL]
XFUNCTION str$prefix (
X  VAR destination_string    : VARYING [A] OF CHAR ;
X  source_string`009`009    : VARYING [B] OF CHAR) : UNSIGNED ; EXTERNAL ;
X
X
X  CONST
X    Cli$_Present    = 261401 ;
X    Cli$_Defaulted  = 261409 ;
X
X
X[ASYNCHRONOUS, EXTERNAL]
XFUNCTION Cli$Get_Value (
X`009In_Par`009    : VARYING[A] OF CHAR ;
X`009VAR Out_Par : VARYING[B] OF CHAR ;
X`009Ret_Len`009    : UNSIGNED := %IMMED 0) : UNSIGNED ; EXTERNAL ;
X
X
X[ASYNCHRONOUS, EXTERNAL]
XFUNCTION Cli$Present (
X`009In_Par : VARYING[A] OF CHAR) : UNSIGNED ; EXTERNAL ;
X
X
X[ASYNCHRONOUS, EXTERNAL]
XPROCEDURE lib$signal (
X  %IMMED condition_value`009: UNSIGNED ;
X  %IMMED number_of_arguments`009: INTEGER := %IMMED 0 ;
X  %IMMED FAO_argument`009`009: [LIST, UNSAFE] INTEGER) ; EXTERNAL ;
X`032
X
X[ASYNCHRONOUS, EXTERNAL]
XFUNCTION lib$do_command (
X  command_string : VARYING [A] OF CHAR) : UNSIGNED ; EXTERNAL ;
X`032
X
XEND `123 of ENVIRONMENT Retrieve_RTL_routines `125.
$ GOSUB UNPACK_FILE

$ FILE_IS = "RET_MSG.MSG"
$ CHECKSUM_IS = 1970473984
$ COPY SYS$INPUT VMS_SHARE_DUMMY.DUMMY
X.TITLE`009    Message facility for the RETRIEVE verb
X
X.FACILITY   RETR, 1/PreFix = RETR_
X
X.IDENT`009    'Sys$Util:Retrieve.Exe'
X
X.SEVERITY   FATAL
X`009    IllPhyVal`009    <!UL is an illegal pointer value>/Fao_Count = 1
X
X.SEVERITY   ERROR
X`009    ErrDurOpen`009    <Error opening file !AS>/Fao_Count = 1
X
X.SEVERITY   WARNING
X`009    IllValRan`009    <Illegal value range>
X`009    CmdNoFou`009    <Unable to find command !AS>/Fao_Count = 1
X`009    CmdNumNoFou`009    <Unable to find command number !UB>/Fao_Count = 1
X
X.SEVERITY   INFORMATION
X`009    NoComFou`009    <No commands found>
X`009    RetrVer`009    <Retrieve, !AS, Jo Torsmyr...>/Fao_Count = 1
X`009    TotOfCmds`009    <Total of !UB command!%S>/Fao_Count = 2
X
X.SEVERITY   SUCCESS
X`009    RecBufFlu`009    <Recall buffer flushed>
X`009    ResFroFil`009    <Commands restored from file !AS>/Fao_Count = 1
X`009    SavOnFil`009    <Commands saved on file !AS>/Fao_Count = 1
$ GOSUB UNPACK_FILE
$ EXIT
-+-+-+-+-+ End of part 5 +-+-+-+-+-

