![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
|
"concerned_netizen" <teks... (AT) yahoo (DOT) com> wrote in message news:19308fa0-0814-4027-968d-9d30478c24f5 (AT) glegroupsg2000goo (DOT) googlegroups.com... I seem to remember how easy it was to take input dates and validate themin 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 No, they cannot. There is no corresponding iconv/oconv for phone numbers. Someone could write one, though. -- frosty |
#5
| |||
| |||
|
|
On Jan 28, 8:00*am, "frosty" <fros... (AT) bogus (DOT) invalid> wrote: "concerned_netizen" <teks... (AT) yahoo (DOT) com> wrote in message news:19308fa0-0814-4027-968d-9d30478c24f5 (AT) glegroupsg2000goo (DOT) googlegroups..com... 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 returninga phone number? p No, they cannot. There is no corresponding iconv/oconv for phone numbers. Someone could write one, though. -- frosty Perhaps something like this? input phone.num if phone.num = "end" then goto fail if phone.num matches "10n" then * *phone.num[4,0] = "-" * *phone.num[8,0] = "-" print phone.num end fail: end input 5552050102 * output 555-205-0102 |
#6
| |||
| |||
|
|
"concerned_netizen" wrote 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 No, they cannot. There is no corresponding iconv/oconv for phone numbers. Someone could write one, though. |
#7
| |||
| |||
|
|
US phone numbers? International? A mix? Steve Yeah, validating phone numbers can be tricky, |
#8
| |||
| |||
|
|
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 |
#9
| |||
| |||
|
|
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 h* 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 hend 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 aphone number? p- Hide quoted text - - Show quoted text - |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |