🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.x.apps
Article #768

Re: X address book

#768
From: Andy Rabagliati
Date: Sat, 26 Jun 1993 06:41
163 lines
5402 bytes
In article <207g7mINNbm0@srvr1.engin.umich.edu> acaird@krazykat.engin.umich.edu (Andrew Justin Caird) writes:
>
>In article <1993Jun22.081701.18427@nmrf.bioch.ox.ac.uk>, mikes@bioch.ox.ac.uk (Mike Smith) writes:
>> 
>> Is there some x application to store names / addresses / etc in a nice
>> friendly way, and then be able to print out the list when necessary?
>
> xrolodex will do the job.  (archie for it). It will let
>you store a lot of stuff and then sort by the first row. 
>I guess you could awk up  (or perl up, or whatever) the address list
>to print more nicely.

This is what I use to sort, format, and print xrolodex databases. It
makes some assumptions about what ya got in there :-

An entry (formatted) looks like this (less the +++ stuff)

+++++++++++++++++++++++++++++++++++++++++++++++++++++
Joe Bloggs          (719)555-1212
  15 Any Street
  Some more address
  Not too long
  This City             CO 80905
--
some comments about this entry
++++++++++++++++++++++++++++++++++++++++++++++++++++

rolodex -h       to see the (few) options.

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  rolodex
# Wrapped by andyr@wizzy on Sat Jun 26 00:39:56 1993
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'rolodex' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'rolodex'\"
else
echo shar: Extracting \"'rolodex'\" \(2778 characters\)
sed "s/^X//" >'rolodex' <<'END_OF_FILE'
X#!/usr/local/bin/perl
X#
X# sort .xrolo database to something prettier
X#
X# printing needs something like this :
X# rolodex -p | groff  -t -mgs -Tps | pstops 0@0.6 | lp
X#
X
Xrequire "getopt.pl";            # Getopt('abc')
X
X$HOME = $ENV{'HOME'};
X
X$ROLODEX = "$HOME/.xrolo";
X
X&Getopt('f');
Xif ($opt_h) {
X        print <<"EndOfHelp";
X
XUsage: rolodex [ options ]
X	sorts .xrolo database to something prettier
X
XOptions:
X        -h      This help
X	-f      Rolodex file - default .xrolo
X	-p	formats for printing addr list
X		rolodex -p | groff  -t -mgs -Tps | lp
XEndOfHelp
X        exit 0;
X}
X$opt_f && ($ROLODEX = $opt_f);
X
Xif ($opt_p) {
X    open(XROLO, $ROLODEX);
X} else {
X    rename($ROLODEX, "xrolo$$");
X    open(XROLO, "xrolo$$");
X    open(NEW, ">$ROLODEX");
X    select (NEW);
X}
X
X$/ = "####\n";
X$* = 1;
X
Xwhile (<XROLO>) {
X    undef (@street, $city, $state, $zip, $rest);
X    s/\t/ /g;				# strip all tabs to spaces
X    s/^ +//g;				# strip all leading spaces
X    s/ +$//g;				# strip trailing spaces
X    s/ +/ /g;				# down to a single space
X    
X    @_ = split(/\n/);
X    $_[$#_] eq "####" && $#_--;	        # strip #### delimiter
X    ($name) = ($_[0] =~ /^([^(+]+)/);	# name up to beginning of phone
X    $name =~ s/ +$//;			# strip trailing spaces
X
X    ($phone) = ($_[0] =~ /(\(\d\d\d\)-?\d\d\d-\d\d\d\d)/);
X    !$phone && (($phone) = ($_[0] =~ /(\+[- \d.]+)/));
X
X    for ($i = 1; ($i <= $#_) && ($_[$i] ne "--") ; $i++) {
X	if (($state,  $zip) = ($_[$i] =~ /(\b[A-Z]{2}\b) *(\d\d\d\d\d)/)) {
X	    if ($_[$i] =~ /^ *(.*\w) +\w\w *\d\d\d\d\d/) {
X		push(@street, $city);
X		$city = $1;
X	    }
X	    last;
X	}
X	$city && push(@street, $city);
X	($city) = ($_[$i] =~ / *(.*)/);
X    }
X    if (!$state) {
X	if ($city =~ /^(.*\w) +(\b[A-Z]{2}\b)/) {
X	    $city = $1;
X	    $state = $2;
X	}
X    }
X    $i++ < $#_ && do {
X	$_[$i] eq "--" && $i++;
X	$rest = join("\n", @_[$i..$#_]);
X    };
X    !$name && next;
X    $addresses {$name} = join('~', $phone,
X			    join(',', @street), $city, $state, $zip, $rest);
X}
X$opt_p && do {
X
X#   l (left) B (bold) 1 (space to next col) p12 (point) I (italic)
X#   v12 (vert. spacing - can't get it to work
X
X    print ".nr PS 5\n.TS\n linesize(20) ;\n";
X    print "l1p7 r1p7 rI1p6 lI1p6 r1p7 lp7.\n";
X    foreach $name (sort keys %addresses) {
X	($phone, $street, $city, $state, $zip, $rest) =
X					split('~', $addresses{$name});
X	printf("%s\t%s\t%s\t%s\t%s\t%s\n",
X			$name, $phone, $street, $city, $state, $zip);
X    }
X    print ".TE\n";
X};
X
X(!$opt_p) && do {
X    foreach $name (sort keys %addresses) {
X	($phone, $street, $city, $state, $zip, $rest) =
X					split('~', $addresses{$name});
X	printf("%-26s%s\n", $name, $phone);
X	$street && printf("  %s\n", $street);
X	printf("  %-25s %s %s\n", $city, $state, $zip);
X	$rest && print "--\n", $rest, "\n";
X	print "####\n";
X    }
X}
END_OF_FILE
if test 2778 -ne `wc -c <'rolodex'`; then
    echo shar: \"'rolodex'\" unpacked with wrong size!
fi
chmod +x 'rolodex'
# end of 'rolodex'
fi
echo shar: End of shell archive.
exit 0
Technical Details
Message-ID: <C97uKu.92C@wizzy.com>
Path: arc1-ca.pugleaf.net!wupost!sdd.hp.com!col.hp.com!wizzy!andyr
References: <1993Jun22.081701.18427@nmrf.bioch.ox.ac.uk> <207g7mINNbm0@srvr1.engin.umich.edu>

Show Full Headers
Complete Article Headers
Newsgroups: comp.windows.x.apps,alt.sources
Path: arc1-ca.pugleaf.net!wupost!sdd.hp.com!col.hp.com!wizzy!andyr
From: andyr@wizzy.com (Andy Rabagliati)
Subject: Re: X address book
Message-ID: <C97uKu.92C@wizzy.com>
Reply-To: andyr@wizzy.com
Organization: W.Z.I.
References: <1993Jun22.081701.18427@nmrf.bioch.ox.ac.uk> <207g7mINNbm0@srvr1.engin.umich.edu>
Date: Sat, 26 Jun 1993 06:41:17 GMT
Lines: 163