home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / private / varapps.zip / AREA230.ZIP / AREA.BAS next >
BASIC Source File  |  1989-12-20  |  18KB  |  381 lines

  1.         'area-code display program
  2.         DEFINT I-O
  3.         CONST true = -1: false = NOT true
  4.         author$ = "Owen Carlson  7609 Dublin Drive, Manassas VA 22110"
  5.         note$ = "Corrections received will be incorporated in next update"
  6.         version$ = "AREA 2.30"
  7.         restorerow = CSRLIN
  8.         restorecolumn = POS(x)
  9.         numcodes = 143
  10.         stlin = 6
  11.         leftcol = 30
  12.         mode = 0: page0 = 0: page1 = 1
  13.         toplin$ = "╒════════════════════════════════════════╕"  'top box line
  14.         botlin$ = "╘════════════════════════════════════════╛"  'bottom line
  15.         xlin$ = "├────────────────────────────────────────┤"    'split line
  16.         midline$ = "│                                        │"  'text line
  17.         '
  18.         DEF SEG = &H40                     'go play with DOS
  19.         invid = PEEK(&H49)
  20.         IF invid < 2 THEN
  21.           PRINT "AREA does not support"
  22.           PRINT "40-column displays."
  23.           END
  24.         END IF
  25.         IF invid > 3 THEN
  26.           PRINT "AREA does not support GRAPHICS modes"
  27.           END
  28.         END IF
  29.         IF invid = 2 THEN ividmode = 0 'black/white
  30.         IF invid = 3 THEN ividmode = 1 'color
  31.         iegapgalines = PEEK(&H84)      'for future testing and use
  32.         '
  33.         'v2.30 philosophy has changed to handle only 80-column displays
  34.         'and to handle mono by PRINTing vice the screen-swap & locate-and-
  35.         'print window method as is done for color.
  36.         'If this causes any problems, please inform me.
  37.         '
  38.         c$ = COMMAND$ 'get command line & strip any leading spaces
  39.         c$ = UCASE$(c$) 'make all letters upper-case
  40. Strip:  IF LEFT$(c$, 1) = " " THEN c$ = RIGHT$(c$, LEN(c$) - 1): GOTO Strip
  41.         GOSUB Shiftscrn    'move page0 to page1, prepare window
  42.         cval = VAL(c$)     'get value of input command field
  43.         middigit$ = MID$(c$, 2, 1)
  44.         flag = false       'set flag false prior to use
  45.         state = false      'ditto
  46.         areacode = false   'ditto
  47.         IF LEN(c$) = 2 THEN state = true       'any 2-char field = state/prov
  48.         IF LEN(c$) = 3 THEN areacode = true    'any 3-char field = area code
  49.         IF NOT state AND NOT areacode THEN
  50.           GOSUB Prsyntax                       'bad syntax, so print syntax
  51.           GOTO Depart                          'screen and depart
  52.         END IF
  53.         IF areacode AND (cval < 201 OR cval > 919) THEN
  54.           GOSUB Prnoarea                       'bad area code, say so and
  55.           GOTO Depart                          'depart
  56.         END IF
  57.         IF areacode AND (middigit$ < "0" OR middigit$ > "1") THEN
  58.           GOSUB Prnoarea              'bad area code number (middle digit
  59.           GOTO Depart                 'not a one or a zero), print syntax and
  60.         END IF                        'depart
  61.         IF areacode THEN                  'look thru
  62.           FOR i = 1 TO numcodes           'data for match
  63.             READ a$                       'on single area
  64.             IF LEFT$(a$, 3) = c$ THEN     'code.
  65.               flag = true                 'Set flag and
  66.               GOSUB Prareacode            'print the match and
  67.               EXIT FOR                    'leave loop when found
  68.             END IF
  69.           NEXT i
  70.           IF flag THEN GOTO Depart
  71.           IF NOT flag THEN                'if flag not set, no match
  72.             GOSUB Prnoarea                'was found, say that no such
  73.             GOTO Depart                   'code exists and depart.
  74.           END IF
  75.         END IF
  76.         IF state THEN                     'listing all the area codes in a
  77.           stateflag = false               'state/province
  78.           FOR i = 1 TO numcodes           'look thru all codes
  79.             READ a$
  80.             ac$ = LEFT$(a$, 3)
  81.             st$ = MID$(a$, 4, 2)
  82.             state$ = MID$(a$, 6, 19)
  83.             region$ = MID$(a$, 25, 37)
  84.             IF MID$(a$, 4, 2) = c$ THEN    'looking for a match on state
  85.               IF NOT stateflag THEN        'if first match,
  86.                 GOSUB PrTopLine            'start the window print
  87.                 txtout$ = state$
  88.                 GOSUB PrMidLine            'print state/province
  89.                 stateflag = true           'and set flag
  90.               END IF
  91.               IF stateflag THEN               'print the data for the code
  92.                 txtout$ = ac$ + " " + region$ 'matches found, including 1st
  93.                 GOSUB PrMidLine
  94.               END IF
  95.             END IF
  96.           NEXT i                           'loop
  97.           IF stateflag THEN                'print the bottom lines of
  98.             GOSUB PrSplitLine
  99.             GOSUB PrBotLines               'the window
  100.             GOSUB Waitescape               'hang on the ESC key
  101.           END IF                           'then drop thru to END
  102.         END IF
  103.         IF NOT stateflag THEN
  104.           GOSUB PrNoState                  'if no state was found, say so
  105.           GOSUB Waitescape                 'hang on ESC
  106.         END IF
  107.         GOSUB Shiftback                    'shift back to the original
  108.         END                                'screen and terminate
  109.         '
  110. Depart: GOSUB Waitescape                   'hang on ESC key
  111. DP2:    GOSUB Shiftback                    'another way out
  112.         END
  113.         '
  114. Shiftback:
  115.         IF ividmode = 0 THEN RETURN           'can't shift in MDA B&W
  116.         SCREEN mode, ividmode, page0, page0   'shift screen back to
  117.         LOCATE restorerow, restorecolumn      'where called from
  118.         RETURN
  119.         '
  120. Shiftscrn:
  121.         IF ividmode = 0 THEN RETURN           'only one page for MDA B&W
  122.         PCOPY page0, page1                    'block copy
  123.         SCREEN mode, ividmode, page1, page1   'set video & active page to 1
  124.         COLOR 0, 7                            'set color for window and
  125.         RETURN                                'return
  126.  
  127. PrNoState:                                    'state not found window
  128.         GOSUB PrTopLine
  129.         txtout$ = c$
  130.         GOSUB PrMidLine
  131.         txtout$ = ""
  132.         GOSUB PrMidLine
  133.         txtout$ = "State/Province not recognized."
  134.         GOSUB PrMidLine
  135.         GOSUB PrSplitLine
  136.         GOSUB PrBotLines
  137.         RETURN
  138.        
  139. Prsyntax:                                        'syntax window
  140.         GOSUB PrTopLine
  141.         txtout$ = "Correct Syntax is:"
  142.         GOSUB PrMidLine
  143.         txtout$ = "           `AREA 616'"
  144.         GOSUB PrMidLine
  145.         txtout$ = "       or  `AREA MI'"
  146.         GOSUB PrMidLine
  147.         GOSUB PrSplitLine
  148.         GOSUB PrBotLines
  149.         RETURN
  150.  
  151. Prareacode:                                         'single area-code window
  152.         st$ = MID$(a$, 4, 2)
  153.         state$ = MID$(a$, 6, 19)
  154.         region$ = MID$(a$, 25, 37)
  155.         GOSUB Shiftscrn
  156.         GOSUB PrTopLine
  157.         txtout$ = "Area Code  = " + c$
  158.         GOSUB PrMidLine
  159.         txtout$ = "State/Prov = " + state$
  160.         GOSUB PrMidLine
  161.         o = LEN(region$)
  162.         oo = 40 - o - 1                      'num of spaces to right-justify
  163.         IF oo > 11 THEN oo = 11              'but don't justify farther
  164.         txtout$ = SPACE$(oo) + region$       'right than under the "="
  165.         GOSUB PrMidLine
  166.         GOSUB PrSplitLine
  167.         GOSUB PrBotLines
  168.         RETURN
  169.  
  170. Prnoarea:                               'no area code found window
  171.         GOSUB PrTopLine
  172.         txtout$ = c$
  173.         GOSUB PrMidLine
  174.         txtout$ = ""
  175.         GOSUB PrMidLine
  176.         txtout$ = "Requested AreaCode does not exist."
  177.         GOSUB PrMidLine
  178.         GOSUB PrSplitLine
  179.         GOSUB PrBotLines
  180.         RETURN
  181.  
  182. PrSplitLine:
  183.         IF ividmode = 0 THEN
  184.           PRINT splitline$
  185.          ELSE
  186.           currentline = currentline + 1
  187.           LOCATE currentline, leftcol
  188.           PRINT xlin$
  189.         END IF
  190.         RETURN
  191.  
  192. PrMidLine:
  193.         q$ = midline$
  194.         MID$(q$, 3, 39) = txtout$
  195.         IF ividmode = 0 THEN
  196.           PRINT q$
  197.          ELSE
  198.           currentline = currentline + 1
  199.           LOCATE currentline, leftcol
  200.           PRINT q$
  201.         END IF
  202.         RETURN
  203.  
  204. PrTopLine:
  205.         currentline = stlin
  206.         IF ividmode = 0 THEN
  207.           PRINT toplin$
  208.          ELSE
  209.           LOCATE currentline, leftcol
  210.           PRINT toplin$
  211.         END IF
  212.         RETURN
  213.  
  214. PrBotLines:
  215.         q$ = midline$
  216.         MID$(q$, 3, 11) = "ESC to Exit"
  217.         MID$(q$, 31, 9) = version$
  218.         IF ividmode = 0 THEN
  219.           PRINT q$
  220.           PRINT botlin$
  221.          ELSE
  222.           currentline = currentline + 1
  223.           LOCATE currentline, leftcol
  224.           PRINT q$
  225.           currentline = currentline + 1
  226.           LOCATE currentline, leftcol
  227.           PRINT botlin$
  228.         END IF
  229.         RETURN
  230.  
  231. Waitescape:                                        'return only
  232. WE2:    x$ = INKEY$                                'when the ESC
  233.         IF x$ = "" THEN GOTO WE2                   'key has been
  234.         IF x$ <> CHR$(27) THEN GOTO WE2            'pressed
  235.         RETURN
  236.  
  237. Datum:  DATA "201NJNew Jersey         (Newark/Northern)"
  238.         DATA "202DCWashington, DC     (all)"
  239.         DATA "203CTConnecticut        (all)"
  240.         DATA "204MBManitoba           (all)"
  241.         DATA "205ALAlabama            (all)"
  242.         DATA "206WAWashington         (Seattle/Vancouver/Western)"
  243.         DATA "207MEMaine              (all)"
  244.         DATA "208IDIdaho              (all)"
  245.         DATA "209CACalifornia         (Fresno/Modesto/Stockton area)"
  246.         DATA "212NYNew York           (New York City)"
  247.         DATA "213CACalifornia         (Los Angeles)"
  248.         DATA "214TXTexas              (Dallas/Northeastern)"
  249.         DATA "215PAPennsylvania       (Philadelphia and Suburbs)"
  250.         DATA "216OHOhio               (Cleveland/Akron/Northeastern)"
  251.         DATA "217ILIllinois           (Springfield/Middle)"
  252.         DATA "218MNMinnesota          (Duluth/Moorehead/Northern)"
  253.         DATA "219INIndiana            (South Bend/FtWayne/Northern)"
  254.         DATA "301MDMaryland           (all)"
  255.         DATA "302DEDelaware           (all)"
  256.         DATA "303COColorado           (Denver/Northern/FarWestern)"
  257.         DATA "304WVWest Virginia      (all)"
  258.         DATA "305FLFlorida            (Miami/SouthEastern + Keys)
  259.         DATA "306SKSaskatchewan       (all)"
  260.         DATA "307WYWyoming            (all)"
  261.         DATA "308NENebraska           (North Platte/Western)"
  262.         DATA "309ILIllinois           (Peoria/Morton & MidWestern)"
  263.         DATA "312ILIllinois           (Chicago)"
  264.         DATA "313MIMichigan           (Detroit/Southeastern)"
  265.         DATA "314MOMissouri           (St.Louis/Eastern)"
  266.         DATA "315NYNew York           (Syracuse/NorthCentral)"
  267.         DATA "316KSKansas             (Wichita/Dodge City/Southern)"
  268.         DATA "317INIndiana            (Indianapolis/Central)"
  269.         DATA "318LALouisiana          (Shreveport/Western)"
  270.         DATA "319IAIowa               (Dubuque/Eastern)"
  271.         DATA "401RIRhode Island       (all)"
  272.         DATA "402NENebraska           (Omaha/Lincoln/Eastern)"
  273.         DATA "403ABAlberta            (all + YT + NT north of AB & MB)"
  274.         DATA "403YTYukon              (all)"
  275.         DATA "403NTNorthwest Terr.    (N. of AB & MB + all of AB & YT)"
  276.         DATA "404GAGeorgia            (Atlanta/Northern)"
  277.         DATA "405OKOklahoma           (Ok.City/all but Northeast)"
  278.         DATA "406MTMontana            (all)"
  279.         DATA "407FLFlorida            (Orlando/Melbourne/Eastern)"
  280.         DATA "408CACalifornia         (San Jose/Monterey/Salinas area)"
  281.         DATA "409TXTexas              (Galveston/SE less Houston)"
  282.         DATA "412PAPennsylvania       (Pittsburgh/Southwestern)"
  283.         DATA "413MAMassachusetts      (Springfield/Western)"
  284.         DATA "414WIWisconsin          (Milwaukee/Racine/GreenBay/SE)"
  285.         DATA "415CACalifornia         (San Francisco/Oakland)"
  286.         DATA "416ONOntario            (Toronto/Niagara Falls region)"
  287.         DATA "417MOMissouri           (Springfield/SW)"
  288.         DATA "418PQQuebec             (Northeastern)"
  289.         DATA "419OHOhio               (Toledo/Northwestern)"
  290.         DATA "501ARArkansas           (all)"
  291.         DATA "502KNKentucky           (Louisville/Paducah/Western)"
  292.         DATA "503OROregon             (all)"
  293.         DATA "504LALouisiana          (New Orleans/Baton Rouge/Eastern)"
  294.         DATA "505NMNew Mexico         (all)"
  295.         DATA "506NBNew Brunswick      (all)"
  296.         DATA "507MNMinnesota          (Rochester/Albert Lea/Southern)"
  297.         DATA "508MAMassachusets       (Worcester/CapeCod/Central)"
  298.         DATA "509WAWashington         (Spokane/Walla Walla/Eastern)"
  299.         DATA "512TXTexas              (San Antonio/Brownsville/Southern)"
  300.         DATA "513OHOhio               (Cincinnati/Sprngfld/Southwestern)"
  301.         DATA "514PQQuebec             (Montreal/Southern)"
  302.         DATA "515IAIowa               (Des Moines/Central)"
  303.         DATA "516NYNew York           (all Long Island)"
  304.         DATA "517MIMichigan           (Lansing/Jackson/Central & N.E.)"
  305.         DATA "518NYNew York           (Albany/Northeastern)"
  306.         DATA "519ONOntario            (London/Windsor/Sarnia)"
  307.         DATA "601MSMississippi        (all)"
  308.         DATA "602AZArizona            (all)"
  309.         DATA "603NHNew Hampshire      (all)"
  310.         DATA "604BCBritish Columbia   (all + NT North of BC)"
  311.         DATA "604NTNorthwest Terr.    (North of BC)"
  312.         DATA "605SDSouth Dakota       (all)"
  313.         DATA "606KNKentucky           (Lexington/Covington/Eastern)"
  314.         DATA "607NYNew York           (Binghampton/Owego/South Central)"
  315.         DATA "608WIWisconsin          (Madison/Southwestern)"
  316.         DATA "609NJNew Jersey         (Trenton/Princeton/Southern)"
  317.         DATA "612MNMinnesota          (Minneapolis/StPaul/Central)"
  318.         DATA "613ONOntario            (Ottawa/Eastern)"
  319.         DATA "614OHOhio               (Columbus/Southeastern)"
  320.         DATA "615TNTennessee          (Nashville/Central & Eastern)"
  321.         DATA "616MIMichigan           (Grand Rapids/N&W Lower Peninsula)"
  322.         DATA "617MAMassachusetts      (Boston & Suburbs)"
  323.         DATA "618ILIllinois           (Centralia/Cairo/Southern)"
  324.         DATA "619CACalifornia         (San Diego/Imperial/Eastern Desert)"
  325.         DATA "701NDNorth Dakota       (all)"
  326.         DATA "702NVNevada             (all)"
  327.         DATA "703VAVirginia           (Roanoke/Fairfax/Western/Northern)"
  328.         DATA "704NCNorth Carolina     (Charlotte/Southwestern)"
  329.         DATA "705ONOntario            (North Bay/Sault Ste Marie & North)"
  330.         DATA "706  Not Used           (all)"
  331.         DATA "707CACalifornia         (Vallejo/Napa/Eureka/North Coastal)"
  332.         DATA "708ILIllinois           (Chicago's Suburbs)"
  333.         DATA "709NFNewfoundland       (all + Labrador (LB) + NT N. of LB)"
  334.         DATA "709LBLabrador           (all + Nwfndlnd (NF) + NT N. of LB)"
  335.         DATA "709NTNorthwest Terr.    (N. of LB + NF(all) + LB(all))"
  336.         DATA "712IAIowa               (Council Bluffs/Western)"
  337.         DATA "713TXTexas              (Houston & Suburbs)"
  338.         DATA "714CACalifornia         (Anaheim/Orange/Palm Springs)"
  339.         DATA "715WIWisconsin          (Eau Claire/Wausau/Northern)"
  340.         DATA "716NYNew York           (Buffalo/Rochester/Western)"
  341.         DATA "717PAPennsylvania       (Harrisburg/Eastern except Phil'a)"
  342.         DATA "718NYNew York           (New York City)"
  343.         DATA "719COColorado           (Pueblo/Alamosa/SCentral/S.E.)"
  344.         DATA "801UTUtah               (all)"
  345.         DATA "802VTVermont            (all)"
  346.         DATA "803SCSouth Carolina     (all)"
  347.         DATA "804VAVirginia           (Richmond/Norfolk/SE)"
  348.         DATA "805CACalifornia         (Bakersfield/San Luis Obispo)"
  349.         DATA "806TXTexas              (Amarillo/Panhandle)"
  350.         DATA "807ONOntario            (Thunder Bay and North/West)"
  351.         DATA "808HIHawaii             (all the Islands)"
  352.         DATA "809PRPuertoRico/VirgIs  (Bermuda/Bahamas/all offshore Is.)"
  353.         DATA "812INIndiana            (Evansville/Columbus/Southern)"
  354.         DATA "813FLFlorida            (Tampa/Fort Myers/Southwestern)"
  355.         DATA "814PAPennsylvania       (Altoona/Erie/Western except S.W.)"
  356.         DATA "815ILIllinois           (Rockford/Northeast except Chicago)"
  357.         DATA "816MOMissouri           (Kansas City/Northwestern)"
  358.         DATA "817TXTexas              (Fort Worth/Temple/NorthCentral)"
  359.         DATA "818CACalifornia         (Alhambra/Burbank/Pasadena area)"
  360.         DATA "819PQQuebec             (Northwestern Quebec + NT N. of PQ)"
  361.         DATA "819NTNorthwest Terr.    (N. of Quebec(PQ) + Northwestrn PQ)"
  362.         DATA "901TNTennessee          (Memphis/Western)"
  363.         DATA "902NSNova Scotia        (all + Prince Edward Island (PE) )"
  364.         DATA "902PEPrince Edward Is.  (all + Nova Scotia (NS) )"
  365.         DATA "903  Not Used                "
  366.         DATA "904FLFlorida            (Jacksonville/Pensacola/Northern)"
  367.         DATA "905  Not Used           (all)"
  368.         DATA "906MIMichigan           (Upper Peninsula)"
  369.         DATA "907AKAlaska             (all)"
  370.         DATA "908  Not Used                "
  371.         DATA "909  Not Used                "
  372.         DATA "912GAGeorgia            (Savannah/Southern)"
  373.         DATA "913KSKansas             (Topeka/KanCity/Northern)"
  374.         DATA "914NYNew York           (Poughkeepsie/lower Hudson Valley)"
  375.         DATA "915TXTexas              (El Paso/San Angelo/Western)"
  376.         DATA "916CACalifornia         (Sacramento/Redding/Northeastern)"
  377.         DATA "917  Not Used                "
  378.         DATA "918OKOklahoma           (Tulsa/Northeastern)"
  379.         DATA "919NCNorth Carolina     (Winston/Salem, Northern & Eastern)"
  380.  
  381.