Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Seek - not exact search? What does influence on it?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00312453
Message ID:
00312955
Vues:
14
Jim,
>
>Here's an example of why I don't like making global environemtn changes if it is not absolutely necessary. The highlighted line is your sample code below would result in EXACT not being reset to the original value.
>
>
>lparameter lcValue && character value to check
>local lcOldExact
>lcOldExact=set('exact') && Save current settings
>set exact on && To perform exact match
>if !empty(this.CursorName) and !empty(lcValue) and type('lcValue')='C'
>   if seek(lcValue,this.CursorName, 'Code') && Check if it's duplicate
>      =messagebox('There is a duplicate! '+lcValue+ ;
>                  ' will not be added!',48,'Warning')
>      <strong>return .f.</strong>
>   endif
>endif
>set exact &lcOldExact && Restore old settings
>return .t.
>
>
>Here's your same code with my way of doing it;
>
>
>LPARAMETERS lcValue && character value to check
>LOCAL llReturn
>llReturn = .T.
>IF !EMPTY(this.CursorName) and !EMPTY(lcValue) and VarType(lcValue)='C'
>   IF SEEK(PADR(lcValue,LEN(FieldName)),this.CursorName, 'Code')
>      =MessageBox('There is a duplicate! '+lcValue+ ;
>                  ' will not be added!',48,'Warning')
>      llReturn = .F.
>   ENDIF
>ENDIF
>RETURN llReturn
>
>
>In this example I have made two changes, one is not chaging SET EXACT at all, but controlling the comparison by padding the lcValue string (this is exactly the same as setting exact on and not padding). The second change is to use a return variable so that there is ONLY ONE return command in the function.

Thanks a lot. This code is considerable better. I continue to learn and gain experience...
BTW, you made even 3 changes :) Vartype is also preferable. I'll change my code and update my classes, which I sent today in UT classes-VCX section.

Thanks again.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform