/* @version 1.0 @output none (library function) * This is a library file which allows other programs to * accommodate my habit of using long place names * (such as "Ridgewood, Bergen, New Jersey, United States"). * To use this code add include("vlong.lllib") to the defines, * put the following 2 lines in main() * * table(abbvtab) * call setupabbvtab() * * and call the function with an string using * * STRING shorten(STRING) * * Paul Buckley Jun 6, 2000 */ global (abbvtab) /*hold a table of abbreviations defined in proc setupabbvtab*/ func shorten (string) { list(parts) set(input,string) set(output,"") extracttokens(input,parts,i,",") set(j,length(parts)) forlist (parts,part,i) { set(success,lookup(abbvtab,part)) if(success) { if(eq(i,1)) { /* this statement provides for either */ concat(output,"in ") /* "in {locale}" or "{date}, {locale}" */ } /* to approximate better English. */ concat(output,success) /* Only works for items in abbvtab. */ } else { concat(output,part) } if (lt(i,j)) { concat(output,", ")} } set(success,lookup(abbvtab,input)) return(output) } proc setupabbvtab () { insert(abbvtab, "Colorado", "CO") insert(abbvtab, "California", "CA") insert(abbvtab, "Connecticut", "CT") insert(abbvtab, "Florida", "FL") insert(abbvtab, "Illinois", "IL") insert(abbvtab, "Ireland", "Ireland") insert(abbvtab, "Maine", "ME") insert(abbvtab, "Maryland", "MD") insert(abbvtab, "Massachusetts", "MA") insert(abbvtab, "New Jersey", "NJ") insert(abbvtab, "New York", "NY") insert(abbvtab, "Nova Scotia", "NS") insert(abbvtab, "Ohio", "OH") insert(abbvtab, "Pennsylvania", "PA") insert(abbvtab, "Rhode Island", "RI") insert(abbvtab, "United States of America", "US") insert(abbvtab, "United States", "US") insert(abbvtab, "Vermont", "VT") insert(abbvtab, "Newfoundland", "NF") insert(abbvtab, "Netherlands", "NT") insert(abbvtab, "Spain", "Spain") }