Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Simplify concantenated line of code
Message
De
17/07/2007 15:36:42
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01241143
Message ID:
01241264
Vues:
35
>>>>>>
>>>>>>FOR ix = 1 to Whatever
>>>>>>    WITH EVALUATE('loObj'+TRANSFORM(m.ix))
>>>>>>         REPLACE JMJ_IN.Diag1 WITH LEFT(ALLTRIM(UPPER(.Field019)),AT('^',.Field019)-1)
>>>>>>    ENDWITH
>>>>>>ENDFOR
>>>>>>
>>>>
>>>>Personally, I'm scared to death of WITH...ENDWITH
>>>>
>>>>http://fox.wikis.com/wc.dll?Wiki~WithLeaksLocals~VFP
>>>
>>>Yep,
>>>When you use some functions or any other EXTERNAL to WITH...ENDWITH could be dangerous, but with simple REPLACE?
>>
>>Absolutely!
>>
>>WITH SOMETHING
>> REPLACE SOMEFIELD WITH MYUDF()
>>ENDWITH
>>
>>MYUDF.PRG
>>IF M.THIS OR .THAT
>>
>>".that" should have been "m.that", but oops. Try to debug this (or THAT) :)
>
>Hmm, I was talk about simple REPLACE :-)
>
>WITH Something
>     REPLACE SOMEFIELD WITH .SomeProperty
>ENDWITH
>
I'm an all or nothing kind of guy, I guess. If the technique does not make things safer, I'm reluctant to use it. .SomeProperty could have an access or assign leaving things open to mistakes. :)

I've had no driving need to use WITH...ENDWITH and feel pretty comfortable with continuing to avoid it. :)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform