Part of the Samples Website. 5/1/97.

samples.records.sample2

«create a mini-database in Frontier's object database
«each item in "statesTable" contains a record
«the name of the item is the state's name
«each record contains
«the name of the state capital
«the state's two-character abbreviation
«the year the state was admitted to the union
«note -- for larger databases, uBASE is much more efficient!
«there are three parts to this script:
«1. we create and populate the table
«2. we check each element of the table to be sure it's there
«3. we build a list of states that were admitted before 1789
local (adrStatesTable = @suites.samples.records.statesTable)
new (tableType, adrStatesTable)
bundle «add 50 states, their capitals and abbreviations
on addState (name, capital, abbrev, yearAdmitted)
adrStatesTable^.[name] = {'capi': capital, 'abbr':abbrev, 'year':yearAdmitted}
addState ("Alabama", "Montgomery", "AL", 1819)
addState ("Alaska", "Juneau", "AK", 1959)
addState ("Arizona", "Phoenix", "AZ", 1912)
addState ("Arkansas", "Little Rock", "AR", 1836)
addState ("California", "Sacramento", "CA", 1850)
addState ("Colorado", "Denver", "CO", 1876)
addState ("Connecticut", "Hartford", "CT", 1788)
addState ("Delaware", "Dover", "DE", 1787)
addState ("Florida", "Tallahassee", "FL", 1845)
addState ("Georgia", "Atlanta", "GA", 1788)
addState ("Hawaii", "Honolulu", "HI", 1959)
addState ("Idaho", "Boise", "ID", 1890)
addState ("Illinois", "Springfield", "IL", 1818)
addState ("Indiana", "Indianapolis", "IN", 1816)
addState ("Iowa", "Des Moines", "IA", 1846)
addState ("Kansas", "Topeka", "KA", 1861)
addState ("Kentucky", "Frankfort", "KY", 1792)
addState ("Louisiana", "Baton Rouge", "LA", 1812)
addState ("Maine", "Augusta", "ME", 1820)
addState ("Maryland", "Annapolis", "MD", 1788)
addState ("Massachusetts", "Boston", "MA", 1788)
addState ("Michigan", "Lansing", "MI", 1837)
addState ("Minnesota", "St. Paul", "MN", 1858)
addState ("Mississippi", "Jackson", "MS", 1817)
addState ("Missouri", "Jefferson City", "MO", 1821)
addState ("Montana", "Helena", "MT", 1889)
addState ("Nebraska", "Lincoln", "NE", 1867)
addState ("Nevada", "Carson City", "NV", 1864)
addState ("New Hampshire", "Concord", "NH", 1788)
addState ("New Jersey", "Trenton", "NJ", 1787)
addState ("New Mexico", "Santa Fe", "NM", 1912)
addState ("New York", "Albany", "NY", 1788)
addState ("North Carolina", "Raleigh", "NC", 1789)
addState ("North Dakota", "Bismarck", "ND", 1889)
addState ("Ohio", "Columbus", "OH", 1803)
addState ("Oklahoma", "Oklahoma City", "OK", 1907)
addState ("Oregon", "Salem", "OR", 1859)
addState ("Pennsylvania", "Harrisburg", "PA", 1787)
addState ("Rhode Island", "Providence", "RI", 1790)
addState ("South Carolina", "Columbia", "SC", 1788)
addState ("South Dakota", "Pierre", "SD", 1889)
addState ("Tennessee", "Nashville", "TN", 1796)
addState ("Texas", "Austin", "TX", 1845)
addState ("Utah", "Salt Lake City", "UT", 1896)
addState ("Vermont", "Montpelier", "VT", 1791)
addState ("Virginia", "Richmond", "VA", 1788)
addState ("Washington", "Olympia", "WA", 1889)
addState ("West Virginia", "Charleston", "WV", 1863)
addState ("Wisconsin", "Madison", "WI", 1848)
addState ("Wyoming", "Cheyenne", "WY", 1890)
bundle «check the states table, make sure everything worked
on checkState (name, capital, abbrev, yearAdmitted)
local (adrStateRecord = @adrStatesTable^ [name])
if adrStateRecord^ ['capi'] [not equal] capital
scriptError ("The capital of " + name + " is really " + capital + ".")
if adrStateRecord^ ['abbr'] [not equal] abbrev
scriptError ("The abbreviation of " + name + " is really " + abbrev + ".")
if adrStateRecord^ ['year'] [not equal] yearAdmitted
scriptError (name + " was really admitted to the union in " + yearAdmitted + ".")
checkState ("Alabama", "Montgomery", "AL", 1819)
checkState ("Alaska", "Juneau", "AK", 1959)
checkState ("Arizona", "Phoenix", "AZ", 1912)
checkState ("Arkansas", "Little Rock", "AR", 1836)
checkState ("California", "Sacramento", "CA", 1850)
checkState ("Colorado", "Denver", "CO", 1876)
checkState ("Connecticut", "Hartford", "CT", 1788)
checkState ("Delaware", "Dover", "DE", 1787)
checkState ("Florida", "Tallahassee", "FL", 1845)
checkState ("Georgia", "Atlanta", "GA", 1788)
checkState ("Hawaii", "Honolulu", "HI", 1959)
checkState ("Idaho", "Boise", "ID", 1890)
checkState ("Illinois", "Springfield", "IL", 1818)
checkState ("Indiana", "Indianapolis", "IN", 1816)
checkState ("Iowa", "Des Moines", "IA", 1846)
checkState ("Kansas", "Topeka", "KA", 1861)
checkState ("Kentucky", "Frankfort", "KY", 1792)
checkState ("Louisiana", "Baton Rouge", "LA", 1812)
checkState ("Maine", "Augusta", "ME", 1820)
checkState ("Maryland", "Annapolis", "MD", 1788)
checkState ("Massachusetts", "Boston", "MA", 1788)
checkState ("Michigan", "Lansing", "MI", 1837)
checkState ("Minnesota", "St. Paul", "MN", 1858)
checkState ("Mississippi", "Jackson", "MS", 1817)
checkState ("Missouri", "Jefferson City", "MO", 1821)
checkState ("Montana", "Helena", "MT", 1889)
checkState ("Nebraska", "Lincoln", "NE", 1867)
checkState ("Nevada", "Carson City", "NV", 1864)
checkState ("New Hampshire", "Concord", "NH", 1788)
checkState ("New Jersey", "Trenton", "NJ", 1787)
checkState ("New Mexico", "Santa Fe", "NM", 1912)
checkState ("New York", "Albany", "NY", 1788)
checkState ("North Carolina", "Raleigh", "NC", 1789)
checkState ("North Dakota", "Bismarck", "ND", 1889)
checkState ("Ohio", "Columbus", "OH", 1803)
checkState ("Oklahoma", "Oklahoma City", "OK", 1907)
checkState ("Oregon", "Salem", "OR", 1859)
checkState ("Pennsylvania", "Harrisburg", "PA", 1787)
checkState ("Rhode Island", "Providence", "RI", 1790)
checkState ("South Carolina", "Columbia", "SC", 1788)
checkState ("South Dakota", "Pierre", "SD", 1889)
checkState ("Tennessee", "Nashville", "TN", 1796)
checkState ("Texas", "Austin", "TX", 1845)
checkState ("Utah", "Salt Lake City", "UT", 1896)
checkState ("Vermont", "Montpelier", "VT", 1791)
checkState ("Virginia", "Richmond", "VA", 1788)
checkState ("Washington", "Olympia", "WA", 1889)
checkState ("West Virginia", "Charleston", "WV", 1863)
checkState ("Wisconsin", "Madison", "WI", 1848)
checkState ("Wyoming", "Cheyenne", "WY", 1890)
local (earlyStates = {})
bundle «generate a list of abbreviations of states that were admitted before 1789
local (i)
for i = 1 to sizeOf (adrStatesTable^)
local (rec = adrStatesTable^ [i])
if rec ['year'] < 1789
earlyStates = earlyStates + rec ['abbr']
dialog.notify ("States admitted before 1789: " + cr + string (earlyStates))


This page was last built on Thu, May 1, 1997 at 12:50:44 AM. You can download the current set of sample scripts from our FTP site. Dave