Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Can this code be faster?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00821524
Message ID:
00821589
Vues:
20
Try using GETWORDNUM(NameField, 1, '*') to help clean up the code.

Cathy


>We are searching records for any condition using a from and to condition. Records are stored like so:
>
>SMITH*JAMES
>SMITH III*MICHAEL
>SMITH JR*JOHN
>SMITHERMAN*PETER
>
>I must account for the user entering from: SA to: SMITH or from: SMITH to: SMITH, or from: A to: Z, etc. SMITH to SMITH should NOT include SMITHERMAN...
>
>The below code works (If exact is on and near is off), but can it be faster?
>
>
>xreturn=.T.  && include this record, .f. if record does not meet condition
>  IF !EMPTY(xfrom) OR !EMPTY(xto)
>    IF ALLTRIM(UPPER(xfrom))=ALLTRIM(UPPER(xto))
>      IF ALLTRIM(UPPER(xfrom)) $ LEFT(UPPER(LEFT(STRTRAN(insured.po_name," ","*",1),;
>          AT("*",STRTRAN(insured.po_name," ","*",1))-1)),LEN(ALLTRIM(UPPER(xfrom)))) ;
>          .AND. UPPER(LEFT(STRTRAN(insured.po_name," ","*",1),;
>          AT("*",STRTRAN(insured.po_name," ","*",1))-1));
>          <= UPPER(ALLTRIM(xto))
>        ? po_name+ "    YES a match"
>        xreturn = .T.
>      ELSE	&& not a match
>        ? po_name+"    NO not a match"
>        xreturn = .F.
>      ENDIF
>    ELSE
>      *--TCH 08/13/2003 * for  SMITH III*JAMES, etc
>      *IF !BETWEEN(UPPER(LEFT(insured.po_name,AT("*",insured.po_name)-1)),xfrom,xto)
>      IF !BETWEEN(UPPER(LEFT(STRTRAN(insured.po_name," ","*",1),;
>          AT("*",STRTRAN(insured.po_name," ","*",1))-1)),xfrom,xto)
>        xreturn = .F.
>      ENDIF
>    ENDIF
>  ENDIF
>
Cathy Pountney, Microsoft Visual FoxPro MVP
Memorial Business Systems, Inc. (www.mbs-intl.com)

My Website: (www.frontier2000.com)
My Blog: (www.cathypountney.blogspot.com)
My Book: The Visual FoxPro Report Writer - Pushing it to the Limit and Beyond
Free MSDN Article: What's New in the VFP 9.0 Report Writer
Free MSDN Article: The VFP 9.0 Report Writer In Action
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform