From: grimaldo@tokyo.seri.philips.nl (Emilio Grimaldo)
Subject: Script corrected 8)
Summary: corrected address book script
Keywords: asearch.awk
Organization: Philips Semiconductors, The Netherlands 
X-Newsreader: Tin 1.1 PL4
Date: Fri, 11 Sep 1992 08:59:14 GMT

Here is the CORRECTED version of the address book script:

===== CUT HERE save as asearch.awk
 
# TITLE : Script for soc.penpals address book. Limited filtering
# AUTHOR: D. Emilio Grimaldo Tunon
# VERSION: 1.01
# 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-Za-z].*_/   {
                country = substr($0,2,length($0)-2)
              }
/\+[A-Za-z].*\+/ {
                    state = substr($1,2,length($1)-2)
              }
/-[A-Za-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

--
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