From: grimaldo@tokyo.seri.philips.nl (Emilio Grimaldo)
Subject: Adr. Book SCRIPT is here!!!
Organization: Philips Semiconductors, The Netherlands 
X-Newsreader: Tin 1.1 PL4
Date: Fri, 11 Sep 1992 08:43:46 GMT

Hi folks!
	 Here is the scripts for the address book, it comprises 2 files:
	     asearch.awk  Program used by the script. Requires no further
			  handling so just save it under that name.
             asearch      Script, save it under that name and then do the
			  following:   chmod a+x asearch   
			  this way it becomes and executable file, to use it
			  do this:
			    asearch  (list ALL entries)
			    asearch male  (list all MALE entries)
			    asearch female (list all FEMALE entries)
			    asearch a_country (list all entries whose country
					       field match 'a_country'
         The address book must have the name 'abook' if you want a different
	 name edit the asearch script.

	 So here are the scripts, have fun!
	 p.s. You have to perform 2 cuts because there are two files.

======= CUT HERE asearch
 
#!/bin/sh
awk -v parm=$1  -f asearch.awk abook

======= CUT HERE asearch.awk


# TITLE : Script for soc.penpals address book. Limited filtering
# AUTHOR: D. Emilio Grimaldo Tunon
# VERSION: 1.00
# DESCR : - Formats the address book entries
#         - Optional filtering for SEX and COUNTRY (command line -v parm=)
# DATE  : 9 Sept 1992
# FORMAT:
#          _COUNTRY_
#          +PROVINCE+            -CITY-
#          real name:email address:sex:birthday:languages :
#               interests
#               last line of interest %%
#
# RESTRICTIONS: . Province or City *cannot* have embedded '-'
#
BEGIN     {
            print "Address Book Lister (w)1992 Emilio Grimaldo"
            country = ""
            interest_field = 0
          }
function show() {
            print  "Country : " country
            printf "City    : %-20s  Prov: %-20s\n",city,state
            printf "Name    :  %-20s Sex: %-6s\n",name,sex
            print "Birthday:  " birthday
            print "Address :  " address
            print "Languages: " languages
            print "Interests:"
            output_enable = 1
          }
function filter() {
                output_enable = 0
                if (parm == "")
                    show()
                if (tolower(parm) == tolower(sex))
                    show()
                if (tolower(parm) == tolower(country))
                    show()
              }
/_[A-z].*_/   {
                country = substr($0,2,length($0)-2)
              }
/\+[A-z].*\+/ {
                    state = substr($1,2,length($1)-2)
              }
/-[A-z /].*-/ {
                    flet = index($0,"-")
                    city = substr($0,flet+1,length($0)-flet-1)
              }
              {
                if (interest_field == 1) {
                    if (index($0,"%%") != 0) {
                        interest = substr($0,1,length($0)-2)
                        interest_field = 0
                    }
                    else
                        interest = $0
                    if (output_enable == 1)
                        print interest
                    if (interest_field == 0 && output_enable == 1)
                        printf "\n\n"
                }
              }
/:$/          {
                split($0,x,":")
                flet = match(x[1],"[A-Za-z]")
                name = substr(x[1],flet,length(x[1])-flet+1)
                address   = x[2]
                sex       = x[3]
                birthday  = x[4]
                languages = x[5]
                filter()
                interest_field = 1
              }
===== CUT HERE end of programs.
--
NAME:    D. Emilio Grimaldo T.                                   _/_/_/_/       
EMAIL:   grimaldo@tokyo.sce.philips.nl                        _/_/_/      
ADDRESS: PO Box 218,BE-540,5600 MD Eindhoven,The Netherlands   _/_/_/_/         
------------------------------------------------------------------------------
     * * PERSONAL OPINIONS AND THEREFORE NOT REPRESENTING MY EMPLOYER * *
------------------------------------------------------------------------------
"Earth's largest project is also going wrong: humanity..." -me
"To love is to smell the fragance of a soul's inner beauty..." -me
Newsgroups: soc.penpals