Table creation/Postal addresses: Difference between revisions

Content added Content deleted
m (Added the Sidef language)
m (→‎version 1: added/changed whitespace and comments, moved a boxed set of REXX program comments to it's own section.)
Line 801: Line 801:
<br>In addition to "state", fields such as province, municipality, ward,
<br>In addition to "state", fields such as province, municipality, ward,
parish, country, etc) could be added without exclusion.
parish, country, etc) could be added without exclusion.
<lang>╔════════════════════════════════════════════════════════════════════════════════╗
<lang rexx>/*REXX program to create/build/list a table of US postal addresses. */
╟───── Format of an entry in the USA address/city/state/zip code structure:──────╣
/*┌────────────────────────────────────────────────────────────────────┐
║ ║
│ Format of an entry in the USA address/city/state/zipcode 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 │
║ be @USA (in any letter case). In addition, the following variable names║
│ name will be shortened to make these comments (and program) easier │
║ (stemmed array tails) will need to be kept uninitialized (that is, not used ║
│ to read; its name will be @USA (in any case). In addition, │
║ for any variable name). To that end, each of these variable names will have an║
│ the following variables names (stemmed array tails) will need to │
║ underscore in the beginning of each name. Other possibilities are to have a ║
│ be kept uninitialized (that is, not used for any variable name). │
║ trailing underscore (or both leading and trailing), or some other special eye─ ║
│ To that end, each of these "hands-off" variable names will have an │
║ catching character such as: ! @ # $ ? ║
│ underscore in the beginning of each name. Other possibilities are │
║ ║
│ to have a trailing underscore (or both leading and trailing), some │
║ Any field not specified will have a value of "null" (which has a length of 0).║
│ other special eye-catching character such as: ! @ # $ ? │
Any field not specified will have a value of "null" (length 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 number of fields could be added (with invalid field testing). ║
│ Any field can contain any number of characters, this can be limited│
╟────────────────────────────────────────────────────────────────────────────────╣
│ by the restrictions imposed by standards or USA legal definitions. │
Any number of fields could be added (with invalid field testing).
@USA.0 the number of entries in the @USA stemmed array.
║ ║
├────────────────────────────────────────────────────────────────────┤
@USA.0 the number of entries in the @USA "array".
nnn is some positive integer of any length (no leading zeroes).║
╟────────────────────────────────────────────────────────────────────────────────╣
│ │
║ @USA.nnn._name is the name of person, business, or a lot description. ║
│ nnn is some positive integer (no leading zeros, it │
╟────────────────────────────────────────────────────────────────────────────────╣
│ can be any length). │
║ @USA.nnn._addr is the 1st street address ║
├────────────────────────────────────────────────────────────────────┤
@USA.nnn._name = name of person, business, or lot description.│
@USA.nnn._addr2 is the 2nd street address
║ @USA.nnn._addr3 is the 3rd street address ║
├────────────────────────────────────────────────────────────────────┤
@USA.nnn._addr = 1st street address
@USA.nnn._addrNN ··· (any number, but in sequential order).
╟────────────────────────────────────────────────────────────────────────────────╣
│ @USA.nnn._addr2 = 2nd street address │
@USA.nnn._addr3 = 3rd street address
@USA.nnn._state is the USA postal code for the state, terrority, etc.
╟────────────────────────────────────────────────────────────────────────────────╣
│ @USA.nnn._addrNN = ... (any number, but in sequential order). │
║ @USA.nnn._city is the official city name, it may include any character. ║
├────────────────────────────────────────────────────────────────────┤
╟────────────────────────────────────────────────────────────────────────────────╣
│ @USA.nnn._state = US postal code for the state/territory/etc. │
║ @USA.nnn._zip is the USA postal zip code, five or ten digit format. ║
├────────────────────────────────────────────────────────────────────┤
╟────────────────────────────────────────────────────────────────────────────────╣
│ @USA.nnn._city = official city name, may include any char. │
║ @USA.nnn._upHist is the update history (who, date and timestamp). ║
├────────────────────────────────────────────────────────────────────┤
╚════════════════════════════════════════════════════════════════════════════════╝</lang>
│ @USA.nnn._zip = US postal zipcode, 5 digit format or │
<lang rexx>/*REXX program creates, builds, and lists a table of U.S.A. postal addresses.*/
│ 10 char format. │
@usa.=; @usa.0=0 /*initialize stemmed array & 1st value.*/
├────────────────────────────────────────────────────────────────────┤
@usa.0=@usa.0+1 /*bump the unique number for usage. */
│ @USA.nnn._upHist = update History (who, date and timestamp). │
call USA '_city' , 'Boston'
└────────────────────────────────────────────────────────────────────┘*/
call USA '_state' , 'MA'
@USA.=; @USA.0=0
call USA '_addr' , "51 Franklin Street"

call USA '_name' , "FSF Inc."
@usa.0=@usa.0+1 /*bump the unique number for use.*/
call @USA '_city','Boston'
call USA '_zip' , '02110-1301'
@usa.0=@usa.0+1 /*bump the unique number for usage. */
call @USA '_state','MA'
call @USA '_addr',"51 Franklin Street"
call USA '_city' , 'Washington'
call @USA '_name',"FSF Inc."
call USA '_state' , 'DC'
call @USA '_zip','02110-1301'
call USA '_addr' , "The Oval Office"
call USA '_addr2' , "1600 Pennsylvania Avenue NW"

call USA '_name' , "The White House"
@usa.0=@usa.0+1 /*bump the unique number for use.*/
call @USA '_city','Washington'
call USA '_zip' , 20500
call @USA '_state','DC'
call USA 'list'
exit /*stick a fork in it, we're all done. */
call @USA '_addr',"The Oval Office"
/*────────────────────────────────────────────────────────────────────────────*/
call @USA '_addr2',"1600 Pennsylvania Avenue NW"
USA: procedure expose @USA.; parse arg what,txt; arg ?; nn=@usa.0
call @USA '_name',"The White House"
if ?=='LIST' then do nn=1 for @usa.0; call lister; end /*nn*/
call @USA '_zip',20500
else do
call @USA 'list'
exit /*stick a fork in it, we're done.*/
call value '@USA.'nn"."what , txt
call value '@USA.'nn".upHist", userid() date() time()
/*───────────────────────────────@USA subroutine────────────────────────*/
end
@USA: procedure expose @USA.; parse arg what,txt; arg ?; nn=@usa.0
if ?\=='LIST' then do
call value '@USA.'nn"."what,txt
call value '@USA.'nn".upHist",userid() date() time()
end
else do nn=1 for @usa.0
call @USA_list
end /*nn*/
return
return
/*────────────────────────────────────────────────────────────────────────────*/
/*───────────────────────────────@USA_tell subroutine───────────────────*/
@USA_tell: _=value('@USA.'nn"."arg(1));
tell: _=value('@USA.'nn"."arg(1))
if _\=='' then say right(translate(arg(1),,'_'),6) "──►" _
if _\=='' then say right(translate(arg(1), , '_'), 6) "──►" _
return
return
/*────────────────────────────────────────────────────────────────────────────*/
/*───────────────────────────────@USA_list subroutine───────────────────*/
@USA_list: call @USA_tell '_name'
lister: call tell '_name'
call @USA_tell '_addr'
call tell '_addr'
do j=2 until _==''
do j=2 until _==''; call tell '_addr'j; end /*j*/
call @USA_tell '_addr'j
call tell '_city'
call tell '_state'
end /*j*/
call @USA_tell '_city'
call tell '_zip'
call @USA_tell '_state'
say copies('', 40)
call @USA_tell '_zip'
return</lang>
'''output''' &nbsp; (data used is within the REXX program):
say copies('─',40)
<pre>
return</lang>
'''output''' (data used is within the REXX program):
<pre style="overflow:scroll">
name ──► FSF Inc.
name ──► FSF Inc.
addr ──► 51 Franklin Street
addr ──► 51 Franklin Street