Jump to content

Table creation/Postal addresses: Difference between revisions

m
→‎version 1: added/changed whitespace and comments, moved a boxed set of REXX program comments to it's own section.
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:
<br>In addition to "state", fields such as province, municipality, ward,
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 notcan specifiedcontain willany havenumber aof valuecharacters, ofthis can be limited "null"by the (length 0).
║ 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. │
@USA.0 Any the number of fieldsentries couldin bethe added (with invalid@USA field testing)stemmed array.
║ ║
├────────────────────────────────────────────────────────────────────┤
@USA.0 nnn the numberis ofsome entriespositive ininteger theof @USAany "array".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_addr2 is =the name2nd ofstreet person,address business, or lot description.│
║ @USA.nnn._addr3 is the 3rd street address ║
├────────────────────────────────────────────────────────────────────┤
@USA.nnn._addr = 1st street address _addrNN ··· (any number, but in sequential order).
╟────────────────────────────────────────────────────────────────────────────────╣
│ @USA.nnn._addr2 = 2nd street address │
@USA.nnn._addr3 = 3rd street address _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_zip' , 'Boston02110-1301'
@usa.0=@usa.0+1 /*bump the unique number for usage. */
call @USA '_state','MA'
call @USA '_addr_city' ,"51 Franklin Street"'Washington'
call @USA '_name_state' ,"FSF Inc." 'DC'
call @USA '_zip_addr' ,'02110-1301' "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_zip' ,'Washington' 20500
call @USA '_state','DClist'
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 call value '@USA.'nn"."what /*stick a fork in it, we're done.*/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
/*────────────────────────────────────────────────────────────────────────────*/
/*───────────────────────────────@USA_tell subroutine───────────────────*/
@USA_telltell: _=value('@USA.'nn"."arg(1));
if _\=='' then say right(translate(arg(1), , '_'), 6) "──►" _
return
/*────────────────────────────────────────────────────────────────────────────*/
/*───────────────────────────────@USA_list subroutine───────────────────*/
@USA_listlister: call @USA_telltell '_name'
call @USA_telltell '_addr'
do j=2 until _==''; call tell '_addr'j; end /*j*/
call @USA_telltell '_addr_city'j
call tell '_state'
end /*j*/
call @USA_telltell '_city_zip'
say call @USA_tell copies('_state', 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.
addr ──► 51 Franklin Street
Cookies help us deliver our services. By using our services, you agree to our use of cookies.