Groups | Search | Server Info | Login | Register


Groups > comp.databases.pick > #2238

Re: old editing technique

From Robert Joslyn <bobjoslynalt@gmail.com>
Newsgroups comp.databases.pick
Subject Re: old editing technique
Date 2011-01-28 20:52 -0800
Organization http://groups.google.com
Message-ID <f2c1d977-5f98-4d01-9c47-b475d4687c26@u4g2000yqi.googlegroups.com> (permalink)
References <19308fa0-0814-4027-968d-9d30478c24f5@glegroupsg2000goo.googlegroups.com> <e66bf2e4-0d89-476e-a51b-ac4f5335a58b@u24g2000prn.googlegroups.com>

Show all headers | View raw


On Jan 28, 7:05 pm, Scott Ballinger <scott.ballin...@gmail.com> wrote:
> In the USA, the proliferation of area code splits and overlays means
> that every phone number should have 10 digits. You should, at a
> minimum, validate the 1st three digits against an area code table. The
> next three digits (the "exchange" part) can be any combination of
> numbers that don't start with a zero or one. If you want to get picky,
> there is a product called nalennd (google it) that has all valid area
> code + exchange combinations.  Lastly, you might want to exclude the
> "obvious" bad numbers, e.g. 9999999, 4567890, 5551212, etc.
>
> Here is a routine I use called clean.phone.sub(). [If you start with
> only 7 digits it resolves the area code given a zip code.]
>
> sub clean.phone.sub(ph,zip)
> * exclude obviously bad phones
> * 04-12-04 asb
> * ph is returned in 10n format else null if ph was bad
> * 01-11-11 asb: test for valid ac+ex using nalennds,
> *                if invalid try for new ac.
>
> include bp area.codes.fmcs
>
> ph = oconv(ph,"mcn")
> begin case
>   case ph matches "10n"
>     ac = ph[1,3]
>     ph = ph[4,7]
>   case ph matches "7n"
>     ac = ""
>   case 1
>     ph = ""
>     return
> end case
>
> p1 = ph[1,1]
> if p1 eq 0 or p1 eq 1 then
>   * phone number can't start with 0 or 1
>   ph = ""
>   return
> end
>
> ok = 0
> begin case  ;* already excluded 0000000 & 1111111 by testing 1st char
>
>   case ph eq "2222222"
>   case ph eq "3333333"
>   case ph eq "4444444"
>   case ph eq "5555555"
>   case ph eq "6666666"
>   case ph eq "7777777"
>   case ph eq "8888888"
>   case ph eq "9999999"
>   case ph eq "1234567"
>   case ph eq "4567890"
>   case ph eq "5551212"
>   case ph eq "4110000"
>   case ph eq "5500000"
>
>   case 1  ; ok = 1
>
> end case
>
> if ok else
>   ph = ""
>   return
> end
>
> ex = ph[1,3]
>
> if ac eq "" then
>
>   if zip eq "" then
>     ph = ""
>     return
>   end
>
>   * try to get good ac from zip.phones:
>
>   zp = zip:".":ex
>   open "zip.phones" to zip.phones else
>     ph = ""
>     return
>   end
>   readv ac from zip.phones,zp,1 else
>     readv ac from zip.phones,zip,1 else
>       ac = ""
>     end
>   end
>
>   if ac eq "" then
>     ph = ""
>     return
>   end
>
> end
>
> * area code must be in format NXX, where N = 2-9
>
> ok = 0
> ac1 = ac[1,1]
>
> begin case
>
>   case ac1 eq 0
>   case ac1 eq 1
>   case ac[2,2] eq 11   ;* N11 reserved
>   case ac[2,1] eq 9    ;* N9X reserved
>   case ac[1,2] eq 37   ;* 37X reserved
>   case ac[1,2] eq 96   ;* 96X reserved
>   case ac eq 222
>   case ac eq 333
>   case ac eq 444
>   case ac eq 555
>   case ac eq 666
>   case ac eq 777
>   case ac eq 999
>   case 1               ; ok = 1
>
> end case
>
> if ok else
>   ph = ""
>   return
> end
>
> open "area.codes" to area.codes else
>   print "can't open 'area.codes' file"
>   ph = ""
>   return
> end
>
> read ac.rec from area.codes,ac else
>   ph = ""
>   return
> end
>
> if ac.rec<area.codes.st.fmc> eq "toll free" then
>   ph = ac:ph
>   return
> end
>
> * test for valid ac+ex via nalennds (does not work for toll free
> numbers)
>
> ac.ex = ac:".":ex
>
> open "nalennds" to nalennds then
>   read x from nalennds,ac.ex else
>
>     * try new area.code(s) from splits, 1st valid one wins
>     ac = ""
>     new.ac.list = ac.rec<area.codes.new.ac.fmc>
>     max = dcount(new.ac.list,@vm)
>     for n = 1 to max
>       new.ac = new.ac.list<1,n>
>       new.ac.ex = new.ac:".":ex
>       read x from nalennds,new.ac.ex then
>         ac = new.ac
>         exit
>       end
>     next n
>
>   end
> end
>
> if ac eq "" then
>   ph = ""
> end else
>   ph = ac:ph
> end
>
> return
>
> /Scott Ballinger
> Pareto Corporation
> Edmonds WA USA
> 206 713 6006
>
>
>
> > I seem to remember how easy it was to take input dates and validate them in basic.
> > Does anyone recall something like
>
> > input x
> > x=iconv(x,'d2/')
> > if x not matches("2n'/'2n'/'2n') then
> > gosub 100;* fail
> > end else
> > value=x
> > end
>
> > can anyone provide the same method for editing a string and returning a phone number?
>
> > p- Hide quoted text -
>
> - Show quoted text -

There are always complications.  In South Florida one must NOT dial 1
before 305 area code if the number is within the "Miami" 305 but must
dial 1 if the number is within the "Keys" 305.  But if you are NOT in
one of the two 305 areas it's not clear how you can direct a calll to
the Keys or Miami if there are duplicate numbers.  Or why the
complication if there are not duplicate numbers.  And of course many
cell phones "think" for you adding further complications.  Next time
305 is split, which apparently will be soon, will be fun.

Back to comp.databases.pick | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

old editing technique concerned_netizen <tekserf@yahoo.com> - 2011-01-27 23:55 -0800
  Re: old editing technique "Alberto" <alberto@tca.it> - 2011-01-29 21:48 +0100
  Re: old editing technique Robert Joslyn <bobjoslynalt@gmail.com> - 2011-01-28 20:52 -0800
  Re: old editing technique Scott Ballinger <scott.ballinger@gmail.com> - 2011-01-28 16:05 -0800
  Re: old editing technique "frosty" <frostyj@bogus.invalid> - 2011-01-28 08:00 -0700

csiph-web