Annotation of www/support.awk, Revision 1.1
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:
! 18: $1 == "0" {
! 19: if (FNR != 1)
! 20: dump();
! 21: reset();
! 22: next;
! 23: }
! 24:
! 25: $1 == "C" { country = substr($0, 2);
! 26: if (country != oldCountry) {
! 27: print "<TR><TD BGCOLOR=\"#FFFF00\" COLSPAN=6 ALIGN=CENTER><B>" country "</B>"
! 28: }
! 29: oldCountry = country
! 30: next
! 31: }
! 32: $1 == "P" { prov = substr($0, 2); next }
! 33: $1 == "T" { city = substr($0, 2); next }
! 34: $1 == "A" { addr = substr($0, 2); next }
! 35: $1 == "O" { org = substr($0, 2); next }
! 36: $1 == "I" { indv = substr($0, 2); next }
! 37: $1 == "B" { phone = substr($0, 2); next }
! 38: $1 == "F" { fax = substr($0, 2); next }
! 39: $1 == "M" { email = substr($0, 2); next }
! 40: $1 == "U" { url = substr($0, 2); next }
! 41: $1 == "N" { note = substr($0, 2); next }
! 42:
! 43: # left over - must be part of note?
! 44: {
! 45: note = note "\n" $0
! 46: next
! 47: }
! 48:
! 49: function dump() {
! 50: print "<TR><TD>" indv "<BR>" org "<BR>" addr
! 51: print " <TD>" city "<BR>" prov
! 52: print " <TD>" phone "<BR>" fax
! 53: print " <TD>"
! 54: print "<A HREF=\"mailto:" email "\">" email "</A>"
! 55: print "<BR>"
! 56: print "<A HREF=\"" url "\">" url "</A>"
! 57: print " <TD>" note
! 58: }
! 59:
! 60: function reset() {
! 61: prov = ""
! 62: city = ""
! 63: addr = ""
! 64: org = ""
! 65: indv = ""
! 66: email = ""
! 67: phone = ""
! 68: fax = ""
! 69: url = ""
! 70: note = ""
! 71: }
! 72:
! 73: END {
! 74: dump(); # don't forget the last guy!
! 75: }