Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Executing Code From A Memo Field?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00085742
Message ID:
00088130
Vues:
35
>>>>>>>>>>Michael,
>>>>>>>>>>
>>>>>>>>>>>Hmm..that was too easy. Why didn't I think of that? Sometimes I wonder if I'm not going through premature senility.
>>>>>>>>>>
>>>>>>>>>>That method will work, but only if you are running within VFP - a distributed executable doesn't have access to the compiler so cannot compile and run a prg file.
>>>>>>>>>>
>>>>>>>>>>If you want to re-distibute you could look for something called CodeBlock (which may be in the library here).
>>>>>>>>>
>>>>>>>>>If the code in his memo filed is a one liner, he could get the contents into a memvar and use either &Memvar or EVAL() to execute the one line of code..
>>>>>>>>
>>>>>>>>If it's multi-line memo then you can go through the loop:
>>>>>>>>
>>>>>>>>for n=1 to memlines(memofield)
>>>>>>>> cCommand=mline(memofield,n)
>>>>>>>> &cCommand.
>>>>>>>>endfor
>>>>>>>>
>>>>>>>
>>>>>>>Good point Ed... Hadn't thought of that..
>>>>>>
>>>>>>Ed,
>>>>>>
>>>>>>Would loop processing work with that setup? Something like:
>>>>>>DO WHILE ...
>>>>>>.
>>>>>>.
>>>>>>ENDDO
>>>>>>
>>>>>>I'm curious rather than accusatory. This would be great if it works, but I've always been under the impression that you're limited to 1 line commands with macro expansion.
>>>>>
>>>>>But number of these commands in your program is unlimited, right? So, it should work.
>>>>
>>>>Ed,
>>>>
>>>>So you're saying that if I had a memo field with the following in it:
>>>>SELECT foobar
>>>>ln_count = 0
>>>>SCAN WHILE foobar.item = "TEST"
>>>> ? foobar.description
>>>> ln_count = ln_count + 1
>>>>ENDSCAN
>>>>? ln_count
>>>>
>>>>That the following code would run it correctly through macro expansion?
>>>>
>>>>for n=1 to memlines(memofield)
>>>> cCommand=mline(memofield,n)
>>>> &cCommand.
>>>>endfor
>>>>
>>>>I tried something similar, but it didn't work. It generates an error when you try to macro expand the initial loop line. Any way around that?
>>>
>>>This code was tested before posted. You probably have syntax error inside memo field code.
>>
>>Ed,
>>
>>Actually, I just tested the following code:
>>
>>Memo field:
>>lnCount = 0
>>FOR i = 1 TO 14
>> ? i
>> lnCount = lnCount + i
>>ENDFOR
>>? lnCount
>>
>>
>>Program code:
>>SELECT file1
>>for n=1 to memlines(memofield)
>> cCommand=mline(memofield,n)
>> &cCommand.
>>endfor
>>
>>I receive a nesting error on the code when it gets to the "FOR i = 1 TO 14" line. The code within the memo field works correctly until I try to macro convert the lines one at a time. This is what I was getting at the loops will not work correctly within a memo field if you try to macro convert them.
>>
>>Rod
>
>Rod, if you would have a patience to look at the end of this thread, you should find the answer there. Surely, loops cannot be 'macrosed' directly, but it wasn't a purpose.

Ed,

I was attempting to respond to your remark that it was not tested. The initial thread never stated whether or not a loop was involved, and yet you consistently side stepped the issue when you posted your possible resolution to how to run code that resides in a memo field (which was an excellent suggestion, and one that I will probably use in the future). I just wanted to clarify that the code was indeed tested and that it does indeed generate an error when using loops.

I appreciate you insights into the product, and I'm sure that at some point you feel that the horse has been sufficiently beaten, but sometimes the quick response can be the incorrect one.

Rod
Rod Lewis
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform