dbTalk Databases Forums  

old editing technique

comp.databases.pick comp.databases.pick


Discuss old editing technique in the comp.databases.pick forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
concerned_netizen
 
Posts: n/a

Default old editing technique - 01-28-2011 , 01:55 AM






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

Reply With Quote
  #2  
Old   
Steve Douglas
 
Posts: n/a

Default Re: old editing technique - 01-28-2011 , 08:42 AM






US phone numbers? International? A mix?

Steve

Reply With Quote
  #3  
Old   
frosty
 
Posts: n/a

Default Re: old editing technique - 01-28-2011 , 09:00 AM



"concerned_netizen" <tekserf (AT) yahoo (DOT) com> wrote

Quote:
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.

--
frosty

Reply With Quote
  #4  
Old   
Specific
 
Posts: n/a

Default Re: old editing technique - 01-28-2011 , 12:15 PM



On Jan 28, 8:00*am, "frosty" <fros... (AT) bogus (DOT) invalid> wrote:
Quote:
"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
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

Reply With Quote
  #5  
Old   
Specific
 
Posts: n/a

Default Re: old editing technique - 01-28-2011 , 12:19 PM



On Jan 28, 11:15*am, Specific <domp... (AT) gmail (DOT) com> wrote:
Quote:
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
These will do the same thing
x = oconv(phone.num, "ml(###-###-####)")
or
x = oconv(phone.num, "ml(#3-#3-#4)")

Reply With Quote
  #6  
Old   
Tony Gravagno
 
Posts: n/a

Default Re: old editing technique - 01-28-2011 , 01:16 PM



I believe the original code segment should have said:

x=oconv(iconv(x,'d'),'d2/')
if x not matches("2n'/'2n'/'2n') then...

Maybe I'm missing something from the OP but for phone numbers I think
the code is fairly straightforward, no custom processor codes
required. Modify below as necessary for phone numbers with
international prefix, 8 digits, etc. :

* Code not tested, might have typos
LOOP
INPUT X
UNTIL X = "" DO
GOSUB VALIDATE.PHONE
IF ERR = "" THEN CRT PHONE ELSE CRT ERR
REPEAT
STOP
VALIDATE.PHONE: * put this in an INCLUDE item
ERR = ""
DIGITS = ICONV(X,"MCN") ; * Just get numbers
IF LEN(DIGITS) < 7 THEN
ERR = "Not enough digits"
RETURN
END
IF LEN(DIGITS) > 10 THEN
ERR = "Too many digits"
RETURN
END
IF LEN(DIGITS) = 7 THEN
DIGITS = LOCAL.AREA : DIGITS
END
PHONE = OCONV(DIGITS,"ML((###) ###-####)")
RETURN


Sure, a function can be created to look like this:

input x
if %ValidatePhone(x) <> "" then ... err

OR you can do something like this (syntax not entirely correct) :

sub = "CALL VALIDATE.PHONE"
....
input x
if oconv(sub,x) <> "" then ... err

but I think those last two options are overkill.

HTH
T

"frosty" wrote:

Quote:
"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.

Reply With Quote
  #7  
Old   
Frank Winans
 
Posts: n/a

Default Re: old editing technique - 01-28-2011 , 02:42 PM



"Steve Douglas" wrote
Quote:
US phone numbers? International? A mix?

Steve
Yeah, validating phone numbers can be tricky,
if you have to clean up input of an uncertain format;
I had a boss once that due to a strong accounting
background and consequent 10-key long familiarity
had a preference to punctuate them as
800.555.1212 instead of (800) 555-1212

In the Dallas area you have a mix of existing 214 and
new 972 area codes -- you _must_ dial the area code
but must _not_ dial the '1' prefix if, say, dialing a place
across the street.

About 20 years ago a man told me that in the small town he
grew up in, they didn't have to dial all 7 digits for local calls...

You may have to retain both the switchboard number and
the person's unique extension. In our shop we permit
xnnnnn and/or ;freeform comment suffixes on telco nums.

The comment field is really handy, like for dating a phone entry.
Many of the people I know seem to change their cell phone
numbers about every three to five years. Or if the info is from
a caller id log, I note it as 'maybe they called from the spouse's
cell phone.'

Reply With Quote
  #8  
Old   
Scott Ballinger
 
Posts: n/a

Default Re: old editing technique - 01-28-2011 , 06:05 PM



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 = ach
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 = ach
end

return


/Scott Ballinger
Pareto Corporation
Edmonds WA USA
206 713 6006

Quote:
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

Reply With Quote
  #9  
Old   
Robert Joslyn
 
Posts: n/a

Default Re: old editing technique - 01-28-2011 , 10:52 PM



On Jan 28, 7:05*pm, Scott Ballinger <scott.ballin... (AT) gmail (DOT) com> wrote:
Quote:
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 = ach
* 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 = ach
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 aphone 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.

Reply With Quote
  #10  
Old   
Ross Ferris
 
Posts: n/a

Default Re: old editing technique - 01-29-2011 , 12:03 AM



On Jan 29, 6:16*am, Tony Gravagno <tony_grava... (AT) nospam (DOT) invalid>
wrote:

What about extensions .... or do you put those in a seperate field
(assuming a "," delay will not work for some reason.

I'm (obviously) not from the US, but I would think that unless you are
using an auto-dialer, the whole question of the leading "1" could be
resolved by the human using the data (hmm, except faxes .... and then
if you had a branch in the Florida Keys and another in Orange County,
then you would need to be location aware for the faxer).

If there are that many "exceptions to the rule" ... or, use something
like skype .... same dialing conventions from/to anywhere :-)

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.