From:	CSBVAX::CSBVAX::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 17-NOV-1988 17:36
To:	MRGATE::"ARISIA::EVERHART"
Subj:	AMAIL -- VMS MAIL with Alias Table


Received: From KL.SRI.COM by CRVAX.SRI.COM with TCP; Wed, 16 NOV 88 21:54:16 PDT
Received: from CUNYVM.CUNY.EDU by KL.SRI.COM with TCP; Wed, 16 Nov 88 21:27:15 PST
Received: from VAXF.COLORADO.EDU by CUNYVM.CUNY.EDU (IBM VM SMTP R1.1) with BSMTP id 9475; Wed, 16 Nov 88 23:27:38 EDT
Date: Wed, 16 Nov 88 18:58 MDT
From: Pete Klammer 303/556-3915 <PKLAMMER%CUDNVR%VAXF.COLORADO.EDU@CUNYVM.CUNY.EDU>
Subject: AMAIL -- VMS MAIL with Alias Table
To: INFO-VAX@KL.SRI.COM
X-VMS-To: INFO-VAX,PKLAMMER

Dear VMS'ers -
        I got a few favorable comments on this locally, so I felt it
might be worth sharing.  With it, I can send mail to this net as
TO: INFO-VAX, or to my brother two networks away as TO: TOM, without
having to remember all the scrambled eggs in the address, and without
having to clutter my logical-name table permanently.  If there's a way
to restrict MAIL to use just some specific logical-name table instead of
the job-wide one, lemme know.  In the following, "8<" = "scissors".
================8<=============AMAIL.DOC================8<===================
Description: AMAIL - aliases for VMS MAIL.
From: PK           Date:  6-OCT-1988 13:45:26

        Q: "What's better than mail?"   A: "AMAIL!"

AMAIL stands for "Aliased MAIL" -- now you can SEND to convenient names which
you define in a simple text-file table.  This can reduce typing errors, bounced
mail, and intimidating frustration with address forms in general.  AMAIL should
make MAIL more convenient and comfortable to use, particularly if you have
complex paths to distant network correspondents.

First, prepare a file of aliases.  On each line, place a name, a tab character,
and the address string for that name.  Name this file AMAIL.ALIASES (that's an
"A" - AMAIL.ALIASES, not MAIL.ALIASES) in your login directory.  For example:

        v--- (Start in column 1)
        !Any non-alphabetic in column 1 is a comment
        PETE            PKLAMMER
        TOM             BITNET%"ZA320A06@UMKCVAX9"      !My brother
        BUDDIES         PETE,TOM                        ^
        STAFF           @SYS$LOGIN:STAFF.DIS            |
        INFO-VAX        IN::"INFO-VAX@KL.SRI.COM"       |
                ^--- (any whitespace: tabs or spaces)   |
                (comment optional after 2nd whitespace)-+

(You can give the file a name other than AMAIL.ALIASES, or use a file in some
directory other than SYS$LOGIN, if you DEFINE AMAIL$ALIASES to point to it.)

Next, add the following line to your LOGIN.COM file:

        $ AMAIL :== SPAWN/NOLOG @SYS$SYSUTIL:AMAIL.COM

(Don't change your definition of MAIL!  If you have MAIL:==MAIL/EDIT, leave
it that way!  The AMAIL procedure will call MAIL, so it better not be calling
itself!)  Now, logout and login to make that line take effect.

If you say AMAIL, you will see some SPAWN messages and then enter regular MAIL.
You can now send mail TO: any of your alias names (no "@" or anything).  When
you exit from MAIL, there will normally be a couple more informational SPAWN
messages.  Note that the alias file is re-read each time you run AMAIL, so
you can edit it over and over with no logout and login required.  Example:

        $ AMAIL
        MAIL> SEND
        TO: BUDDIES
        SUBJ: ...

Notice that no "@" is used in the TO: line.  However, the "@" is still required
in your aliase definition if you are getting addresses from an indirect file.

How it work?  Your definition of AMAIL starts up a dependent process with
SPAWN, and gives that process its first command: @SYS$SYSUTIL:AMAIL.COM.  What
AMAIL.COM does is look for a file named AMAIL.ALIASES, then AMAIL$ALIASES, and
then SYS$LOGIN:AMAIL.ALIASES, whichever it finds first.  As each line of the
file is read, a DEFINE/PROCESS command is generated.  That means a logical name
(which is what MAIL uses for TO: translations) is defined, but only temporarily
for the duration of the spawned process.  When you exit from MAIL, AMAIL.COM
ends and the SPAWN'ed process terminates -- all those logical names for MAIL
purposes are forgotten, so they won't clutter up your file activities.

[pfk]
================8<================AMAIL.COM================8<================
$!      AMAIL.COM -- Run mail with aliases defined from a file.
$ SAVE_VERIFY := 'COMMANDS$DEBUG        ! to see more, set COMMANDS$DEBUG == 1
$ SAVE_VERIFY = 'F$VERIFY( SAVE_VERIFY .AND. F$VERIFY( ) )
$ COMMANDS$DEBUG := 'COMMANDS$DEBUG
$ GOTO START    ! even in VERIFY mode, economize logging
$
$! This command runs MAIL, with aliases (logicals) defined only during MAIL.
$!
$! REVISION HISTORY
$!      11-Nov-1988     pfk     Any non-alph in col 1 is a comment line.
$!      9-Nov-1988      pfk     OOps!  Defined MAIL/EDIT here; not my business!
$!      22-Oct-1988     pfk     DEFINE with /NOLOG so no "%REDEFINED" msgs.
$!      14-Oct-1988     pfk     Oops... off by one; lost trailing ""'s there.
$!      14-Oct-1988     pfk     Allow any whitespace in alias table
$!      6-Oct-1988      pfk     Default AMAIL$ALIASES to AMAIL.ALIASES or
$!                              SYS$LOGIN:AMAIL.ALIASES, whichever find first.
$!                              That is, DEFINE AMAIL$ALIASES has precedence.
$!      2-Oct-1988      pfk     First edition.
$! END REVISION HISTORY
$
$START:
$ STATUS = 1
$ ON CONTROL_Y THEN GOTO ABORT
$ ON WARNING THEN GOTO ABORT
$ SAY := WRITE SYS$OUTPUT
$ TAB := "      "
$ SPACE := " "
$ SET PROC/NAME=AMAIL
$
$ X = F$TRNLNM( "AMAIL$ALIASES" )
$ IF X .NES. "" THEN -
        GOTO DEFINED
$ Y = F$SEARCH( "AMAIL.ALIASES" )
$ IF Y .EQS. "" THEN -
        GOTO DEFAULT
$ DEFINE/PROCESS AMAIL$ALIASES 'Y'
$ GOTO DEFINED
$DEFAULT:
$ DEFINE/PROCESS AMAIL$ALIASES SYS$LOGIN:AMAIL.ALIASES
$DEFINED:
$ OPEN/READ/ERROR=NONE ALIASES AMAIL$ALIASES
$NEXT:
$ READ/END=EOF ALIASES LINE
$ IF COMMANDS$DEBUG THEN -
        SHOW SYMBOL LINE
$ LINE = F$EDIT( LINE, "COMPRESS,UPCASE" )
$ C = F$EXTRACT( 0, 1, LINE )   ! Any non-alphabetic in col 1 is comment line
$ IF C .LTS. "A" .OR. C .GTS. "Z" THEN -
        GOTO NEXT
$ S1 = F$LOCATE( SPACE, LINE )
$ S2 = S1 + F$LOCATE( SPACE, F$EXTRACT( S1+1, 999, LINE ) )
$ LINE = F$EXTRACT( 0, S2+1, LINE )
$ IF COMMANDS$DEBUG THEN -
        SHOW SYMBOL LINE
$ WHO = F$ELEMENT( 0, SPACE, LINE )
$ IF COMMANDS$DEBUG THEN -
        SHOW SYMBOL WHO
$ WHAT = F$ELEMENT( 1, SPACE, LINE )
$ IF COMMANDS$DEBUG THEN -
        SHOW SYMBOL WHAT
$ CHECK = WHO + SPACE + WHAT
$ IF LINE .EQS. CHECK THEN -
        GOTO OK
$ SAY "?INCORRECT FORMAT IN LINE; SHOULD BE WHO-{WHITESPACE}-WHAT"
$ SAY "- with optional -{WHITESPACE}-COMMENTS after that"
$ GOTO ABORT
$OK:
$ IF F$EXTRACT( 0, 1, WHAT ) .EQS. """" THEN -
        GOTO QUOTED
$ WHAT = """" + WHAT
$ I = 1
$LOOP:
$ IF F$EXTRACT( I, 1, WHAT ) .NES. """" THEN -
        GOTO NOTQUOTE
        WHAT = F$EXTRACT( 0, I+1, WHAT ) + F$EXTRACT( I, 99, WHAT )
$ I = I + 1
$NOTQUOTE:
$ I = I + 1
$ IF I .LE. F$LENGTH( WHAT ) THEN -
        GOTO LOOP
$ WHAT = WHAT + """"
$QUOTED:
$ DEFINE/PROCESS/NOLOG 'WHO' 'WHAT'
$ IF COMMANDS$DEBUG THEN -
        SHOW LOGICAL 'WHO'
$ GOTO NEXT
$NONE:
$ SAY -
 "?NO ALIASES FOUND; is file AMAIL.ALIASES or logical AMAIL$ALIASES defined?"
$ WAIT 0:00:02
$EOF:
$ CLOSE/ERROR=IGNORE ALIASES
$IGNORE:
$ DEFINE/USER SYS$INPUT SYS$COMMAND
$ MAIL
$
$ GOTO END
$ABORT:
$ WRITE SYS$OUTPUT "?[''F$ENVIRONMENT(""PROCEDURE"")': ABORT!]"
$ SET NOCONTROL=Y ! be sure control-Y trapping cleared
$ SET CONTROL=Y
$ STATUS = 4 + %X10000000 ! failure + message already shown
$ IF COMMANDS$DEBUG THEN -
        SHOW SYMBOL/LOCAL/ALL
$
$END:
$ CLOSE/ERROR=IGNORED ALIASES
$IGNORED:
$ IF COMMANDS$DEBUG THEN -
        SHOW SYMBOL STATUS
$ SAVE_VERIFY := 'F$VERIFY(SAVE_VERIFY)'
$ EXIT STATUS
================8<================end================8<================
/**
 * --poko       Pete Klammer, Systems Programmer, (303)556-3915
 *              CU-Denver Computing Services / Campus Box 169
 *              1200 Larimer St NC2506 / Denver CO 80204-5300
 *              BITNET%"PKLAMMER@CUDENVER"
 *              INTERNET%"PKLAMMER%CUDNVR@VAXF.COLORADO.EDU"
 *****************************************************************
 * " I'm half Estonian, which makes up for the other half. "
 *****************************************************************
**/

