Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simplifying code
Message
De
25/11/2005 15:26:11
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
24/11/2005 10:46:15
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP1
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01071897
Message ID:
01072147
Vues:
36
>Sorry, I misread your message, I think we agree. Here is the changed version. But it really contains more characters, so the version with the Select line is shorter. :-)

The fellow asked for simpler, not shorter. ;) If you really want shorter, chop the "cpplan.expr" to just "expr" UNLESS you related two or more cursors and are trying to update fields in both cursors at once. The IN clause makes the "cpplan." totally extraneous.
>Procedure updLabel
>  Lparameters p1, p2, p3, p4
>  For x=1 to 4
>    replace cpplan.expr WITH Evaluate('p'+Transform(x)) in cpplan
>    skip in cpplan
>  Next
>EndProc
>
>>It's so "vital" I don't write ANY replaces without it. ;)
>>
>>>Oh yes, it's vital if you are at the "ghost" record in the current work area, record number reccount()+1.
>>>
>>>>No need for the SELECT cpplan if you use the in clause in the replace and skip ;)
>>>>
>>>>>
>>>>>Procedure updLabel
>>>>>  Lparameters p1, p2, p3, p4
>>>>>  SELECT cpplan
>>>>>  For x=1 to 4
>>>>>    replace cpplan.expr WITH Evaluate('p'+Transform(x))
>>>>>    skip
>>>>>  Next
>>>>>EndProc
>>>>>
>>>>>>Is there anyway I can cut this code down maybe using a for statement or something?
>>>>>>
>>>>>>
>>>>>>PROCEDURE UpdLabel
>>>>>>	LPARAMETERS lcfieldlabel1, lcfieldlabel2, lcfieldlabel3, lcfieldlabel4
>>>>>>	SELECT cpplan
>>>>>>	replace cpplan.expr WITH "'"+ALLTRIM(lcfieldlabel1)+"'" &&lcfieldlabel1
>>>>>>	SKIP
>>>>>>	replace cpplan.expr WITH "'"+ALLTRIM(lcfieldlabel2)+"'" &&lcfieldlabel2
>>>>>>	SKIP
>>>>>>	replace cpplan.expr WITH "'"+ALLTRIM(lcfieldlabel3)+"'" &&lcfieldlabel3
>>>>>>	SKIP
>>>>>>	replace cpplan.expr WITH "'"+ALLTRIM(lcfieldlabel4)+"'" &&lcfieldlabel4
>>>>>>ENDPROC
>>>>>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform