From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX"  8-JUL-1992 15:37:31.14
To:	info-vax@kl.sri.com
CC:	
Subj:	Oops! bug in proc for Re: Aliases for VMS MAIL

Sorry folks!
There was a bug in the previously posted procedure for maintenance of alias 
lists that resulted in problems for lines with trailing spaces.
Here follows updated version that also produces a deassign file.

Procedure allows users to set up a file of abbreviations or aliases such as 
JANE_DOE which can be used in VMS MAIL for the complicated e-mail address:
BITNET%"JANE_DOE%FICTIONAL!SILLY@NONESUCH.BITNET"
and it will create a set of define statements with the double and treble 
quotes required.
Included below is the procedure and a sample input file

----------------------cut here for quote_addresses.com -----------------------
$!   Procedure takes a file called ALIASES.LIS which should consist of
$!   lines with the alias, a space, then the mail address. It creates the 
$!   files ALIASES.COM and KILL_ALIASES.COM 
$!   ALIASES can be included in or called from a login.com, or if called before
$!   entering MAIL and KILL_ALIASES.COM is called _after_ running MAIL then
$!   the problem of aliases being mistakenly translated as logical names 
$!   for files etc. will never occur.                        Ver 2.0
$!  
$!   pete smtp%"pb@vcp.monash.edu.au"            in the input produces
$!   $ define pete "smpt%""pb@vcp.monash.edu.au"""    in   ALIASES.COM 
$! & $ deassign pete                               in KILL_ALIASES.COM 
$!       
$ wrb = "write sys$output"
$ open/read filein ALIASES.LIS
$ open/write fileout ALIASES.COM
$ open/write fileout2 KILL_ALIASES.COM
$readloop:
$ read/end_of_file=eof filein line_in
$ line_in = f$edit(line_in, ("COMPRESS, TRIM"))
$ space = f$locate(" ", line_in)
$ if space .eq. f$length(line_in) 
$ then
$!  no space found - can't process line
$   wrb "Cant process line ",line_in, "  No space in line"
$   wrb "File lines should be of form ALIAS  space  then MAIL ADDRESS"
$   goto readloop
$ endif
$ alias = f$extract(0,space+1,line_in) 
$ q1 = f$locate("""", line_in)
$ if q1 .eq. f$length(line_in) 
$ then
$!   No quotes found, so quote the second word 
$   rest =  """" + f$extract(space+1,999,line_in) + """" 
$ else
$   seg2 = f$extract(q1+1,999,line_in)
$   q2 = f$locate("""", seg2) 
$!  If no second matching quote, then be kind and tack it on the end
$   if q2+1 .lt. f$length(seg2) 
$   then
$!  Second quote not at end of line - can't process line
$     wrb "Cant process line ",line_in, "  Second quote not at end"
$     wrb "File lines should be of form ALIAS  space  then MAIL ADDRESS"
$     goto readloop
$   endif
$   if q2 .eq. f$length(seg2) then seg2 = seg2 + """" 
$   rest =  """" + f$extract(space+1,q1-space,line_in) + """" + seg2 + """""" 
$ endif
$ write fileout "$ define " +  alias + rest
$ write fileout2 "$ deassign " + alias
$ wrb "$ define " +  alias + rest
$ goto readloop
$eof:
$ close fileout
$ close fileout2
$ close filein
$ wrb "   Files ALIASES.COM and KILL_ALIASES.COM have been created"
--------------------- end of quote_addresses.com---------------------
--------------------- sample mail_aliases.lis file-------------------
JANE_DOE BITNET%"JANE_DOE%FICTIONAL!SILLY@NONESUCH.BITNET"
pete smtp%"pb@vcp.monash.edu.au"      
fred organic::S924756
*-----------------------------------*--------------------------------------*
* Peter Bury                        *    Phone : (61 3) 389 9512           *
* Victorian College of Pharmacy     *    Fax   : (61 3) 389 9583           *
* Monash University                 *                                      *
* Melbourne, Australia              *    E-Mail: pb@vcp.monash.edu.au      *
*-----------------------------------*--------------------------------------*

