Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Transform code in function
Message
From
17/02/2014 13:14:24
Mike Yearwood
Toronto, Ontario, Canada
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01594485
Message ID:
01594499
Views:
43
>Hi
>
>I developed a code to correct @Hotmail mistypes, but I have to use it in many parts of my software.
>
>Is it possible to transform it in a function, and which part of it can become a function ?
>
>
>
>select corrige_email
>
>SCAN FOR corrige_email.email_1 = " "
>
>   
>   IF   "@hotmail.com.br" $ corrige_email.email_x  .OR.;
>        "@hotimail" $ corrige_email.email_x  .OR. ".co.br" $ corrige_email.email_x .OR. ;
>        "@hotemail" $ corrige_email.email_x  .OR.;
>        "@hotamil" $ corrige_email.email_x  .OR.;
>        "@hotmais" $ corrige_email.email_x  .OR.;
>        "@hotml" $ corrige_email.email_x  .OR.;
>        "@hotmaiil" $ corrige_email.email_x  .OR.;
>        "@hotmil" $ corrige_email.email_x .or.;
>        "@hotmill" $ corrige_email.email_x .or.;
>        "@hotmaio" $ corrige_email.email_x .or.;
>        "@hotmai" $ corrige_email.email_x .or.;
>        "@htmail" $ corrige_email.email_x .or. "@homail" $ corrige_email.email_x .or.;                         
>        "@hotmaol" $ corrige_email.email_x .or.;
>        "@rotmail" $ corrige_email.email_x .or.;
>        "@hotmal" $ corrige_email.email_x .or.;
>        "@hotm" $ corrige_email.email_x .or.;   && se der certo substitui quase todos
>        "@hotmel" $ corrige_email.email_x 
>                STORE corrige_email.email_x TO lcValue  
>                      
>        replace corrige_email.email_1 with  LEFT(lcValue,AT("@",lcValue)-1)+"@hotmail.com"
>
> 
>
>   ENDIF
>   
>    ENDSCAN
>
>
Adding to what Dragan said, this way you move the testing of bad hotmail spellings to a single location. That means you can maintain that list in a single location.
BADHOTMAIL.PRG
LPARAMETERS m.tcOriginal
if inlist(m.tcOriginal, "hotm", "rotmail", "htmail", ...)
  return .t.
endif
return .f.
lcServer=getwordnum(corrige_email.email_x, "@", 2)
IF BADHOTMAIL(m.lcServer)
   replace corrige_email.email_1 with  getwordnum(corrige_email.email_x, "@", 1)+"@hotmail.com"
endif
You could also create a table of bad hotmail spellings and then allow for something like this...
replace corrige_email.email_1 with  ;
  strtran(corriege_email_x,getwordnum(corrige_email.email_x, "@", 2),"@hotmail.com") ;
  for corrige_email.email_1 = " " and seek(getwordnum(corrige_email.email_x, "@", 2)
Previous
Reply
Map
View

Click here to load this message in the networking platform