[comp.os.vms] TABBER utility - Remove 4 sequential blanks with a tab

ACSCCRA@UBVMSC.CC.BUFFALO.EDU ("Curtis R. Anderson") (05/19/88)

Seeing some of the more interesting files and collections that have been
posted to INFO-VAX, I offer a utility that was originally written as a quick
patch to take files mailed by Internet, which can convert a tab to four
blanks.  This program turns four blanks in sequence back to a tab.

I can't say much as to its usefulness, but give it a shot, anyway...

I must apologize for the fact that the program isn't as 'polished' as it
should be.  I wanted to handle wildcards, but I didn't get it in this version.

Enjoy...

  --Curtis R. Anderson

acsccra@ubvms.bitnet
acsccra@ubvmsc.cc.buffalo.edu
acsccra@sunybcs.uucp
....................... Cut between dotted lines and save ......................
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-5.01 01-Oct-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by ACSCCRA
$! on Thursday 19-MAY-1988 10:46:17.77
$!
$! It contains the following 4 files:
$! TABBER.PAS TABBERM.MSG TABBER.CLD TABBER.HLP
$!==============================================================================
$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set(Output_File,b,o);
Position(Beginning_of(b));Loop x:=Erase_Character(1);Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;
Move_Horizontal(-Current_Offset);EndLoop;Move_Vertical(1);
ExitIf Mark(None)=End_of(b) EndLoop;Position(Beginning_of(b));Loop
x:=Search("`",Forward,Exact);ExitIf x=0;Position(x);Erase_Character(1);
If Current_Character='`' then Move_Horizontal(1);else
Copy_Text(ASCII(INT(Erase_Character(3))));EndIf;EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="TABBER.PAS"
$ Check_Sum_is=53169703
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
Xprogram Tabber(Input, Output, InFile, OutFile);
X(*
X * tabber
X * installs tabs in place of 4 blanks
X *
X * Curtis r. anderson
X * University Computing Services student consultant
X * State University of New York at Buffalo
X *
X * bitnet: acsccra@ubvms.bitnet
X * internet: acsccra@ubvmsc.cc.buffalo.edu
X *
X * Since ARPA sends out files with four blanks in place of a tab, this
X * program is intended to put the tab back in where the blanks existed.  This
X * is useful for converting the .crclst files it sends, and several other
X * programs which use tabs and are sent 'raw' over SIMTEL20.
X *
X * development history:
X *
X * 1.00a - 19-may-87: Turbo Pascal version for use in cp/m and ms-dos
X *                    environments.
X * 2.00a - 19-may-87: VAX Pascal version for use in VAX/VMS environments.
X * 2.00b - 01-jun-87: Corrected a few small problems before release.
X *                    Tightened up comments.
X * 2.1-003,02-sep-87: Making more VMS-able, providing CLI and Message support.
X *
X * CP/M is a registered trademark of Digital Research, Inc.
X * MS-DOS is a registered trademark of Microsoft, Inc.
X * VAX, VMS are registered trademarks of Digital Equipment Corporation.
X *)
X 
Xconst
X  Spaces                                = '    ';
X  Tab
X(* there is a TAB inside the quotes.  If you received this file via ARPA, you
X * will have to use an editor to reinstall the tab again, which is exactly the
X * intended purpose of this program!
X *)                                     = '`009';
X 
X(* VAX/VMS specific constants:  CLI Condition Values *)
X
X  CLI$_ABSENT                           = %X'000381F0';
X  CLI$_NEGATED`009`009`009`009= %X'000381F8';
X  CLI$_LOCNEG`009`009`009`009= %X'00038230';
X  CLI$_PRESENT                          = %X'0003FD19';
X  CLI$_DEFAULTED`009`009`009= %X'0003FD21';
X  CLI$_LOCPRES`009`009`009`009= %X'0003FD31';
X
X(* VAX-11 Message values compiled for this program: *)
X
X  TAB_COMPLETED                         = %X'080A8009';
X  TAB_OPENED                            = %X'080A8013';
X
Xtype
X  Line                                  = Varying[80] of Char; (* for VAX *)
X  RMSFileSpecification                  = Varying[255] of Char;
X
Xvar
X  Verbose                               : Boolean;
X  Cond`009`009`009`009`009: Integer;
X  InFileName, OutFileName               : RMSFileSpecification;
X  InFile, OutFile                       : Text;
X  CommandLength                         : Integer;
X 
X[EXTERNAL, ASYNCHRONOUS] function LIB$SIGNAL(
X  %IMMED condition       `009`009: [UNSAFE] Integer;
X  %IMMED FAO_Params                     : [UNSAFE, LIST] Integer)
X`009`009`009`009`009: [UNSAFE] Unsigned;
X
X  Extern;
X                                          
X[EXTERNAL] function CLI$GET_VALUE(
X  %DESCR   entity_desc                  : Line;
X  %DESCR   retdesc                      : RMSFileSpecification;
X  %REF     retlength                    : Integer := %IMMED 0)
X                                        : Integer;
XExtern;
X
X[EXTERNAL] function CLI$PRESENT(
X  %DESCR   entity_desc                  : Line)
X                                        : Integer;
XExtern;
X
X[EXTERNAL] procedure Message(
X  %IMMED   Id                           : Integer;
X  %IMMED   FAOVal                       : Unsigned := %IMMED 0);
X
XExtern;
X
Xprocedure ProcessFile(
X  var InP                               : Text;
X  var OutP                              : Text
X);
X 
Xvar
X  I                                     : Integer;
X  InpLine                               : Line;
X 
Xbegin
X  repeat
X    ReadLn(InP, InpLine);
X    if Length(InpLine) <= 4 then
X      WriteLn(OutP, InpLine) (* no tabs in such a short line! *)
X    else
X    begin
X      I := 1;
X      while (I <= Length(InpLine) - 3) do
X      begin
X        if SubStr(InpLine, I, 4) = Spaces then (* VAX *)
X        begin
X          Write(OutP, Tab);
X          I := I + 3;
X        end
X        else
X        begin
X          Write(OutP, SubStr(InpLine, I, 1)); (* VAX *)
X        end; (* if *)
X        I := I + 1;
X      end; (* while *)
X      WriteLn(OutP, SubStr(InpLine, Length(InpLine) - 2, 3)); (* VAX *)
X    end; (* if *)
X  until EOF(InP);
Xend;
X 
Xbegin (* main *)
X  (* begin VAX *)
X  InFileName := '';
X  CommandLength := 0;
X  while (CLI$GET_VALUE('INFILE', InFileName, CommandLength) <> CLI$_ABSENT)
X  do
X  begin
X    Cond := CLI$PRESENT('VERBOSE');
X    if (Cond = CLI$_PRESENT) or (Cond = CLI$_LOCPRES) then
X      Verbose := True;
X    if (Cond = CLI$_LOCPRES) or (Cond = CLI$_LOCNEG) or (Cond = CLI$_DEFAULTED)
X    then
X      Verbose := False;
X    Open(InFile, InFileName, History := old);
X    Open(OutFile, InFileName, History := new); (* end VAX *)
X    Reset(InFile);
X    ReWrite(OutFile);
X    if Verbose then
X      LIB$SIGNAL(TAB_OPENED, 1, %STDESCR InFileName);
X    ProcessFile(InFile, OutFile);
X    if Verbose then
X      LIB$SIGNAL(TAB_COMPLETED, 1, %STDESCR InFileName);
X    Close(InFile);
X    Close(OutFile)
X  end;
Xend.
$ GoSub Convert_File
$ File_is="TABBERM.MSG"
$ Check_Sum_is=1278817165
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X`009`009.title`009`009TABBER
X`009`009.ident`009`009"V1.0-001"
X`009`009.facility`009TABBER,10/prefix=TAB_
X`009`009.severity`009success
XCOMPLETED`009<File !AS converted sucessfully>/FAO_COUNT=1
X`009`009.severity`009informational
XOPENED`009`009<File !AS has been opened>/FAO_COUNT=1
X`009`009.end
$ GoSub Convert_File
$ File_is="TABBER.CLD"
$ Check_Sum_is=1394634515
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
V!************************************TABBER************************************
X*
Xdefine verb TABBER
X!
X! change "image" to point to the directory the program is installed in.
X!
X   image TABBER.EXE
X   parameter P1 , prompt="File"
X      value (required,list,type=$file)
X   qualifier LOG
X      placement=positional
X   qualifier OUTFILE
X      value (required,type=$file)
X      placement=local
X   qualifier EXCLUDE_FILE
X      value (required,list,type=$file)
X      placement=local
$ GoSub Convert_File
$ File_is="TABBER.HLP"
$ Check_Sum_is=604384893
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X1 TABBER
X
X  TABBER is a facility  which, when  invoked, will replace  a series  of
X  four blanks with a  tab.   Now, one  will ask  why this  is done;  the
X  reason is that the Internet  will convert  a tab to  four blanks  when
X  the mailers mail files to various  Internet sites.  This program  will
X  dutifully restore  ANY  four blanks,  even  ones not  intended  to  be
X  replaced, with a tab.   This  will help  in interpreting  some of  the
X  news articles  originally  posted  to  USENET  and  gatewayed  to  the
X  Internet special interest  groups  (SIG's).    If  one  receives  a  C
X  program with many tabs in it via Internet, TABBER will put a sense  of
X  order  back  into  the   program  that  was   lost  in  the   mailing.
X
X  Format:
X
X    TABBER file-spec[,...]
X
X2 Parameters
X
X file-spec
X
X  One or more files in a list to be  tabbed.  The  tabbed files will  be
X  of  the   same  name,   but   with  an   increased   version   number.
X
X2 Command_Qualifiers
X
X/LOG
X
X /NOLOG (default)
X /LOG
X
X  Enables transmission  of  all  messages to  the  console  of  severity
X  SUCCESS and INFORMATIONAL.  Otherwise,  these messages are  supressed,
X  to keep from  cluttering up  the screen  when many  files are  tabbed.
X
X2 Errors
X
X  In general, the term "error"  is used  to describe any  of the  system
X  messages generated by this program of the form:
X
X  %FACILITY-I-MSGID, Message text
X
X  where:
X
X  FACILITY is the name of the utility in question;
X  I        is the severity of the message,  where the letter is S, I, W,
X           E, or F;
X  MSGID    is a mnemonic of  up to  nine letters in  length.   Normally,
X           the HELP entries for  "Errors" will be  constructed with  the
X           MSGID values for keys.   When  this program  gives a  message
X           for a reason  that  you don't  understand, please  check  the
X           HELP  entry  to   see   why  the   message   was   generated.
X
X3 INFILE
X
X  MESSAGE: %TABBER-I-INFILE
X
X  TEXT:    Input file is <tabbed-file>
X
X  EXPLANATION:
X           TABBER sucessfully parsed  and opened the  file specified  in
X           the command  line.     Normally  supressed   by  the   /NOLOG
X           qualifier.
X
X3 COMPLETED
X
X  MESSAGE: %TABBER-S-COMPLETED
X
X  TEXT:
X
X  EXPLANATION:
X           TABBER sucessfully tabbed the file and closed it.
X
X2 Author
X
X  Curtis R. Anderson (ACSCCRA@UBVMS.BITNET)
X                     (ACSCCRA@UBVMSC.CC.BUFFALO.EDU)
$ GoSub Convert_File
$ Exit