Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Simplify concantenated line of code
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP1
Miscellaneous
Thread ID:
01241143
Message ID:
01241163
Views:
28
>>>>How to simplify this to remove the EVALUATE() and make it more readable?
>>>>
>>>>
>>>>FOR ix = 1 to Whatever
>>>>     REPLACE JMJ_IN.Diag1 WITH LEFT(ALLTRIM(UPPER(EVALUATE('loObj'+LTRIM(STR(m.ix))+".Field019"))),AT('^',EVALUATE('loObj'+LTRIM(STR(m.ix))+".Field019"))-1)
>>>>ENDFOR
>>>>
>>>
>>>
>>>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
>>>
>>
>>I forget that I can use WITH in PRG code! Thanks!
>
>Oh, is this a v9 thing?

No, it would work in other versions as well. But I'm with you, I would rather have one extra variable to improve readability, e.g.

loRecord = evaluate('loObj' + TRANSFORM(m.ix))

Or

lcProperty = GETPEM(lcObjName, lcPropertyName)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform