Re: Normalizing Dates and Phone numbers

This WebDNA talk-list message is from

2000


It keeps the original formatting.
numero = 26730
interpreted = N
texte = At 8:59 PM -1000 2000/01/29, Kenneth Grome wrote:> >At 9:26 PM -0800 2000/01/29, Chuck Rice wrote: >> >>>At 5:00 PM -1000 2000/01/29, Kenneth Grome wrote: >>> >>>>Here, use this database with the convertchars context. It will get rid of everything that's not a number, then you can format the resulting string of digits with some getchars contexts ... or you can leave the resulting string as it is, which will result in 4085551212 based on your examples above: >>> >>>Thanks! Here is what I came up with. Seems to handle most cases. -Chuck- >>> >>>[!] >>>[\!][GetChars start=8&end=10&from=end]00000000000[ConvertChars db=Strip.db][var1][/ConvertChars][/GetChars]-[!] >>>[\!][GetChars start=5&end=7&from=end]00000000000[ConvertChars db=Strip.db][var1][/ConvertChars][/GetChars]-[!] >>>[\!][GetChars start=1&end=4&from=end]00000000000[ConvertChars db=Strip.db][var1][/ConvertChars][/GetChars] >> >>Ok, Now I am confused again. The above works for output, but I need to process the >>input from a field before it gets written to the database. >> >>I put the above code in an include file called -NormalizePhone and set it up so I could invoke it with: >> > > > [include file=-NormalizePhone&var1=[HPhone]] >> >>My input field is in a form Which then invokes a completion routine that has: >> >>[showif [action]=Replace] >> > > >[replace db=AddressBook.db&eqSKUdatarq=[url][sku][/url]] [!] >>[\!][formvariables name=_&exact=F][getchars start=2][name][/getchars]=[url][value][/url]&[/formvariables] [!] > >[\!][/replace] >> >>
Record Replaced

>> >>[commitdatabase db=AddressBook.db] >>[/showif] >> >>In it. Where do I put the include to change the phone number? It seems to be in the formvariables. That use of the formvariables context is a shortcut that sends all the formvariables beginning with _ to the replace context to be replaced directly, without any preprocessing. > >If you want to process the phone number value *before* putting it into the database, you have to write a different replace context -- one that replaces each field individually. Try using something like this on the page following your form: > >[text]strippedPhoneValue=[ConvertChars db=Strip.db][phoneFieldFromForm][/ConvertChars][/text] > >[text]finalPhoneValue=[GetChars start=8&end=10&from=end][strippedPhoneValue][/GetChars]-[GetChars start=5&end=7&from=end][strippedPhoneValue][/GetChars]-[GetChars start=1&end=4&from=end][strippedPhoneValue][/GetChars][/text] > >[replace]field1=[url][formField1][/url]& ... &phone=[url][finalPhoneValue][/url]&field99=[url][formField99][/url][/replace] >Ugh... I was hoping for something more maintainable. What happens if I do this:[replace db=AddressBook.db&eqSKUdatarq=[url][sku][/url]] [!] [\!]&HPhone=[include file=-NormalizePhone&var1=[HPhone]] [!] Home [\!]&WPhone=[include file=-NormalizePhone&var1=[WPhone]] [!] Work [\!]&CPhone=[include file=-NormalizePhone&var1=[CPhone]] [!] Cell [\!]&PPhone=[include file=-NormalizePhone&var1=[PPhone]] [!] Pager [\!]&FPhone=[include file=-NormalizePhone&var1=[FPhone]] [!] Fax [\!][formvariables name=_&exact=F][getchars start=2][name][/getchars]=[url][value][/url]&[/formvariables] [!] [\!][/replace]This would mean that the phone fields would be specified twice, once explicitly and once in the form Variables. Which value would be used, the first or the second. The rest of the form variables would remain automatic. -Chuck-__________________________________________________________________________ Chuck Rice ------------------------------------------------------------- Brought to you by CommuniGate Pro - The Buzz Word Compliant Messaging Server. To end your Mail problems go to .This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Associated Messages, from the most recent to the oldest:

    
  1. Re: Normalizing Dates and Phone numbers (Chuck Rice 2000)
  2. Re: Normalizing Dates and Phone numbers (Kenneth Grome 2000)
  3. Re: Normalizing Dates and Phone numbers (Chuck Rice 2000)
  4. Re: Normalizing Dates and Phone numbers (Chuck Rice 2000)
  5. Re: Normalizing Dates and Phone numbers (Kenneth Grome 2000)
  6. Re: Normalizing Dates and Phone numbers (Aaron Lynch 2000)
  7. Normalizing Dates and Phone numbers (Chuck Rice 2000)
At 8:59 PM -1000 2000/01/29, Kenneth Grome wrote:> >At 9:26 PM -0800 2000/01/29, Chuck Rice wrote: >> >>>At 5:00 PM -1000 2000/01/29, Kenneth Grome wrote: >>> >>>>Here, use this database with the convertchars context. It will get rid of everything that's not a number, then you can format the resulting string of digits with some getchars contexts ... or you can leave the resulting string as it is, which will result in 4085551212 based on your examples above: >>> >>>Thanks! Here is what I came up with. Seems to handle most cases. -Chuck- >>> >>>[!] >>>[\!][GetChars start=8&end=10&from=end]00000000000[ConvertChars db=Strip.db][var1][/ConvertChars][/GetChars]-[!] >>>[\!][GetChars start=5&end=7&from=end]00000000000[ConvertChars db=Strip.db][var1][/ConvertChars][/GetChars]-[!] >>>[\!][GetChars start=1&end=4&from=end]00000000000[ConvertChars db=Strip.db][var1][/ConvertChars][/GetChars] >> >>Ok, Now I am confused again. The above works for output, but I need to process the >>input from a field before it gets written to the database. >> >>I put the above code in an include file called -NormalizePhone and set it up so I could invoke it with: >> > > > [include file=-NormalizePhone&var1=[HPhone]] >> >>My input field is in a form Which then invokes a completion routine that has: >> >>[showif [action]=Replace] >> > > >[replace db=AddressBook.db&eqSKUdatarq=[url][sku][/url]] [!] >>[\!][formvariables name=_&exact=F][getchars start=2][name][/getchars]=[url][value][/url]&[/formvariables] [!] > >[\!][/replace] >> >>
Record Replaced

>> >>[commitdatabase db=AddressBook.db] >>[/showif] >> >>In it. Where do I put the include to change the phone number? It seems to be in the formvariables. That use of the formvariables context is a shortcut that sends all the formvariables beginning with _ to the replace context to be replaced directly, without any preprocessing. > >If you want to process the phone number value *before* putting it into the database, you have to write a different replace context -- one that replaces each field individually. Try using something like this on the page following your form: > >[text]strippedPhoneValue=[ConvertChars db=Strip.db][phoneFieldFromForm][/ConvertChars][/text] > >[text]finalPhoneValue=[GetChars start=8&end=10&from=end][strippedPhoneValue][/GetChars]-[GetChars start=5&end=7&from=end][strippedPhoneValue][/GetChars]-[GetChars start=1&end=4&from=end][strippedPhoneValue][/GetChars][/text] > >[replace]field1=[url][formField1][/url]& ... &phone=[url][finalPhoneValue][/url]&field99=[url][formField99][/url][/replace] >Ugh... I was hoping for something more maintainable. What happens if I do this:[replace db=AddressBook.db&eqSKUdatarq=[url][sku][/url]] [!] [\!]&HPhone=[include file=-NormalizePhone&var1=[HPhone]] [!] Home [\!]&WPhone=[include file=-NormalizePhone&var1=[WPhone]] [!] Work [\!]&CPhone=[include file=-NormalizePhone&var1=[CPhone]] [!] Cell [\!]&PPhone=[include file=-NormalizePhone&var1=[PPhone]] [!] Pager [\!]&FPhone=[include file=-NormalizePhone&var1=[FPhone]] [!] Fax [\!][formvariables name=_&exact=F][getchars start=2][name][/getchars]=[url][value][/url]&[/formvariables] [!] [\!][/replace]This would mean that the phone fields would be specified twice, once explicitly and once in the form Variables. Which value would be used, the first or the second. The rest of the form variables would remain automatic. -Chuck-__________________________________________________________________________ Chuck Rice ------------------------------------------------------------- Brought to you by CommuniGate Pro - The Buzz Word Compliant Messaging Server. To end your Mail problems go to .This message is sent to you because you are subscribed to the mailing list . To unsubscribe, E-mail to: To switch to the DIGEST mode, E-mail to Chuck Rice

DOWNLOAD WEBDNA NOW!

Top Articles:

Talk List

The WebDNA community talk-list is the best place to get some help: several hundred extremely proficient programmers with an excellent knowledge of WebDNA and an excellent spirit will deliver all the tips and tricks you can imagine...

Related Readings:

Add a field to the error log? (1997) [ot] g5 xserve drives (2004) WebCat2b12--[searchstring] bug (1997) Quickie question on the email templates (1997) Mozilla/4. and Browser Info.txt (1997) suffix mapping, use of cache, etc. (1997) [AppendFile] problem (WebCat2b13 Mac .acgi) (1997) group searching problem (2002) Upgrading from version (1998) OT - help.. (2003) Re:[ShowIf] and empty fields (1997) [SearchString] problem with [search] context (1997) ListFiles (1998) OT: Advice (2003) WebCat2.0 acgi vs plugin (1997) Bug or syntax error on my part? (1997) Server problem? (1998) Shipping charges (1998) SiteEdit NewFile.html ? (1997) Return records from another (1997)