Table creation/Postal addresses: Difference between revisions

Content added Content deleted
No edit summary
m (→‎version 1: simplified some code, added/changed comments and whitespace, arranged subroutines into alphabetical order, corrected some characters used for boxen.)
Line 876: Line 876:
parish, country, etc) could be added without exclusion.
parish, country, etc) could be added without exclusion.
<br>A logging facility is included which tracks who (by userID) did what update (or change), along with a timestamp.
<br>A logging facility is included which tracks who (by userID) did what update (or change), along with a timestamp.
<pre>
<lang>╔════════════════════════════════════════════════════════════════════════════════╗
╔═════════════════════════════════════════════════════════════════════════════════╗
╟───── Format of an entry in the USA address/city/state/zip code structure:──────╣
╟───── Format of an entry in the USA address/city/state/zip code structure: ──────╢
║ ║
║ The "structure" name can be any legal variable name, but here the name will be ║
shortened to make these comments (and program) easier to read; its name will ║
The "structure" name can be any legal variable name, but here the name will be
║ shortened to make these comments (and program) easier to read; its name will ║
║ be @USA (in any letter case). In addition, the following variable names║
║ be @USA (in any letter case). In addition, the following variable names ║
║ (stemmed array tails) will need to be kept uninitialized (that is, not used ║
║ (stemmed array tails) will need to be kept uninitialized (that is, not used
║ for any variable name). To that end, each of these variable names will have an║
underscore in the beginning of each name. Other possibilities are to have a
for any variable name). To that end, each of these variable names will have an
trailing underscore (or both leading and trailing), or some other special eye─
║ underscore in the beginning of each name. Other possibilities are to have a
║ trailing underscore (or both leading and trailing), or some other special eye─ ║
catching character such as: ! @ # $ ?
catching character such as: ! @ # $ ?
║ Any field not specified will have a value of "null" (which has a length of 0).║
║ Any field not specified will have a value of "null" (which has a length of 0).
║ ║
║ Any field can contain any number of characters, this can be limited by the ║
restrictions imposed by the standards or the USA legal definitions.
Any field can contain any number of characters, this can be limited by the
Any number of fields could be added (with invalid field testing).
restrictions imposed by the standards or the USA legal definitions. ║
║ Any number of fields could be added (with testing for invalid fields). ║
╟────────────────────────────────────────────────────────────────────────────────╣
╟─────────────────────────────────────────────────────────────────────────────────╢
║ @USA.0 the number of entries in the @USA stemmed array.
@USA.0 the number of entries in the @USA stemmed array.
nnn is some positive integer of any length (no leading zeroes).
║ nnn is some positive integer of any length (no leading zeroes). ║
╟────────────────────────────────────────────────────────────────────────────────╣
╟─────────────────────────────────────────────────────────────────────────────────╢
║ @USA.nnn._name is the name of person, business, or a lot description. ║
║ @USA.nnn._name is the name of person, business, or a lot description.
╟────────────────────────────────────────────────────────────────────────────────╣
╟─────────────────────────────────────────────────────────────────────────────────╢
║ @USA.nnn._addr is the 1st street address ║
║ @USA.nnn._addr2 is the 2nd street address ║
║ @USA.nnn._addr is the 1st street address
║ @USA.nnn._addr3 is the 3rd street address ║
║ @USA.nnn._addr2 is the 2nd street address
║ @USA.nnn._addrNN ··· (any number, but in sequential order).
║ @USA.nnn._addr3 is the 3rd street address
║ @USA.nnn._addrNN ··· (any number, but in sequential order) .
╟────────────────────────────────────────────────────────────────────────────────╣
╟─────────────────────────────────────────────────────────────────────────────────╢
║ @USA.nnn._state is the USA postal code for the state, terrority, etc. ║
║ @USA.nnn._state is the USA postal code for the state, territory, etc.
╟────────────────────────────────────────────────────────────────────────────────╣
╟─────────────────────────────────────────────────────────────────────────────────╢
║ @USA.nnn._city is the official city name, it may include any character. ║
║ @USA.nnn._city is the official city name, it may include any character.
╟────────────────────────────────────────────────────────────────────────────────╣
╟─────────────────────────────────────────────────────────────────────────────────╢
║ @USA.nnn._zip is the USA postal zip code, five or ten digit format. ║
║ @USA.nnn._zip is the USA postal zip code (five or ten digit format). ║
╟────────────────────────────────────────────────────────────────────────────────╣
╟─────────────────────────────────────────────────────────────────────────────────╢
║ @USA.nnn._upHist is the update history (who, date and timestamp).
║ @USA.nnn._upHist is the update history (who, date, and timestamp). ║
╚════════════════════════════════════════════════════════════════════════════════╝</lang>
╚═════════════════════════════════════════════════════════════════════════════════╝
<lang rexx>/*REXX program creates, builds, and lists a table of U.S.A. postal addresses.*/
</pre>
@usa.=; @usa.0=0 /*initialize stemmed array & 1st value.*/
<lang rexx>/*REXX program creates, builds, and displays a table of given U.S.A. postal addresses.*/
@usa.0=@usa.0+1 /*bump the unique number for usage. */
@usa.=; @usa.0=0 /*initialize stemmed array & 1st value.*/
call USA '_city' , 'Boston'
@usa.0=@usa.0+1 /*bump the unique number for usage. */
call USA '_state' , 'MA'
call USA '_addr' , "51 Franklin Street"
call USA '_city' , 'Boston'
call USA '_name' , "FSF Inc."
call USA '_state' , 'MA'
call USA '_zip' , '02110-1301'
call USA '_addr' , "51 Franklin Street"
@usa.0=@usa.0+1 /*bump the unique number for usage. */
call USA '_name' , "FSF Inc."
call USA '_city' , 'Washington'
call USA '_zip' , '02110-1301'
@usa.0=@usa.0+1 /*bump the unique number for usage. */
call USA '_state' , 'DC'
call USA '_addr' , "The Oval Office"
call USA '_city' , 'Washington'
call USA '_addr2' , "1600 Pennsylvania Avenue NW"
call USA '_state' , 'DC'
call USA '_name' , "The White House"
call USA '_addr' , "The Oval Office"
call USA '_zip' , 20500
call USA '_addr2' , "1600 Pennsylvania Avenue NW"
call USA 'list'
call USA '_name' , "The White House"
exit /*stick a fork in it, we're all done. */
call USA '_zip' , 20500
call USA 'list'
/*────────────────────────────────────────────────────────────────────────────*/
exit /*stick a fork in it, we're all done. */
USA: procedure expose @USA.; parse arg what,txt; arg ?; nn=@usa.0
/*──────────────────────────────────────────────────────────────────────────────────────*/
if ?=='LIST' then do nn=1 for @usa.0; call lister; end /*nn*/
list: call tell '_name'
else do
call value '@USA.'nn"."what , txt
call tell '_addr'
call value '@USA.'nn".upHist", userid() date() time()
do j=2 until $==''; call tell "_addr"j; end /*j*/
end
call tell '_city'
call tell '_state'
return
call tell '_zip'
/*────────────────────────────────────────────────────────────────────────────*/
tell: _=value('@USA.'nn"."arg(1))
say copies('', 40)
return
if _\=='' then say right(translate(arg(1), , '_'), 6) "──►" _
/*──────────────────────────────────────────────────────────────────────────────────────*/
return
tell: $=value('@USA.'#"."arg(1));if $\='' then say right(translate(arg(1),,'_'),6) "──►" $
/*────────────────────────────────────────────────────────────────────────────*/
return
lister: call tell '_name'
/*──────────────────────────────────────────────────────────────────────────────────────*/
call tell '_addr'
USA: procedure expose @USA.; parse arg what,txt; arg ?; @='@USA.'
do j=2 until _==''; call tell '_addr'j; end /*j*/
if ?=='LIST' then do #=1 for @usa.0; call list; end /*#*/
call tell '_city'
call tell '_state'
else do
call value @ || @usa.0 || . || what , txt
call tell '_zip'
call value @ || @usa.0 || . || 'upHist', userid() date() time()
say copies('─', 40)
end
return</lang>
return</lang>
'''output''' &nbsp; (data used is within the REXX program):
'''output''' &nbsp; (data used is within the REXX program):