Groups | Search | Server Info | Login | Register


Groups > comp.databases.pick > #2184

Re: old editing technique

From Tony Gravagno <tony_gravagno@nospam.invalid>
Newsgroups comp.databases.pick
Subject Re: old editing technique
Date 2011-01-28 11:16 -0800
Organization Nebula R&D
Message-ID <rct5k6tr3qep8raqdjjha2ege5j2eld9nc@4ax.com> (permalink)
References <19308fa0-0814-4027-968d-9d30478c24f5@glegroupsg2000goo.googlegroups.com> <ihulmj$i0o$1@news.eternal-september.org>

Show all headers | View raw


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:

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

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


Thread

Re: old editing technique Tony Gravagno <tony_gravagno@nospam.invalid> - 2011-01-28 11:16 -0800
  Re: old editing technique "bill_tidy@yahoo.co.uk" <bill_tidy@yahoo.co.uk> - 2011-01-29 08:29 -0800
  Re: old editing technique Ross Ferris <rossf@stamina.com.au> - 2011-01-28 22:03 -0800

csiph-web