[BACK]Return to groups.awk CVS log [TXT][DIR] Up to [local] / www

Annotation of www/groups.awk, Revision 1.2

1.1       ian         1: #!/usr/bin/nawk -f
                      2:
                      3: # convert data like this (order doesn't matter except 0 at front)
                      4: # 0
                      5: # C Canada
                      6: # P Ontario
                      7: # T Palgrave
                      8: # A R R # 1
                      9: # O Consultant
                     10: # I Ian F. Darwin
                     11: # M ian@darwinsys.com
                     12: # U http://www.darwinsys.com
                     13: # N Author of lots of kool stuff.
                     14:
                     15: # into HTML to make nice neat tables.
                     16:
                     17:
1.2     ! ian        18: $1 ~ /^#/ { next; }
        !            19:
1.1       ian        20: $1 == "0" {
                     21:        if (FNR != 1)
                     22:                dump();
                     23:        reset();
                     24:        next;
                     25:        }
                     26:
                     27: $1 == "C" { country = substr($0, 2);
                     28:        if (country != oldCountry) {
                     29:                print "<TR><TD BGCOLOR=\"#FFFF00\" COLSPAN=6 ALIGN=CENTER><B>" country "</B>"
                     30:         }
                     31:        oldCountry = country
                     32:        next
                     33: }
                     34: $1 == "P" { prov = substr($0, 2); next }
                     35: $1 == "T" { city = substr($0, 2); next }
                     36: $1 == "A" { addr = substr($0, 2); next }
                     37: $1 == "O" { org = substr($0, 2); next }
                     38: $1 == "I" { indv = substr($0, 2); next }
                     39: $1 == "B" { phone = substr($0, 2); next }
                     40: $1 == "F" { fax = substr($0, 2); next }
                     41: $1 == "M" { email = substr($0, 2); next }
                     42: $1 == "U" { url = substr($0, 2); next }
                     43: $1 == "N" { note = substr($0, 2); next }
                     44:
                     45: # left over - must be part of note?
                     46:        {
                     47:        note = note "\n" $0
                     48:        next
                     49:        }
                     50:
                     51: function dump() {
1.2     ! ian        52:        print "<TR><TD>"
        !            53:        if (indv != "")
        !            54:                print indv "<BR>"
        !            55:        print org "<BR>" addr
1.1       ian        56:        print " <TD>" city "<BR>" prov
                     57:        print " <TD>" phone "<BR>" fax
                     58:        print " <TD>"
                     59:                print "<A HREF=\"mailto:" email "\">" email "</A>"
                     60:                print "<BR>"
                     61:                print "<A HREF=\"" url "\">" url "</A>"
                     62:        print " <TD>" note
                     63: }
                     64:
                     65: function reset() {
                     66:        prov = ""
                     67:        city = ""
                     68:        addr = ""
                     69:        org = ""
                     70:        indv = ""
                     71:        email = ""
                     72:        phone = ""
                     73:        fax = ""
                     74:        url = ""
                     75:        note = ""
                     76: }
                     77:
                     78: END {
                     79:        dump();         # don't forget the last guy!
                     80: }