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:
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:
WebCat & WebTen (1997)
Alcatraz must have been nicer than this... (2000)
webCatalog, OSX, and WebStar (2001)
Page Breaks (1999)
New user...how do I create URLs from form fields? (2000)
Standardize Address :: USPS (2005)
Re:2nd WebCatalog2 Feature Request (1996)
Wits end with this [sendmail] problem. ;) (2000)
WebCatalog can't find database (1997)
SetHeader not Working (2006)
New Weird Behavior (bug report) (2000)
Searchable WebCat (etc.) Docs ? (1997)
Protect (1997)
RE: Emailer prefs in two places ... (1997)
carriage returns in data (1997)
It finally happened ... (2003)
OR in Showifs (Was: Secure Web Server) (1999)
SSL and reg web* (1997)
searchable list archive (1997)
Almost a there but..bye bye NetCloak (1997)