Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
.fxp structure info?
Message
 
À
19/09/1998 16:20:42
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00138666
Message ID:
00138711
Vues:
9
Hi Albert,

Sure, it's actually quite easy. I wrote such a tool in a limited version myself a long time ago. You have mainly to check every line whether it starts with IF, ENDIF, ELSE, DO WHILE, FOR, ENDFOR, SCAN, ENDSCAN, TEXT, ENDTEXT, DO CASE, CASE, OTHERWISE, ENDCASE etc. Every other line you execute via macro substitution. Lines that contain the above control structures have to be handled by yourself. You parse out the parameter like the condition in IF, then look for the corresponding end block code (ELSE or ENDIF), get this block and call the program recursively to execute it as well. You can do it itereraively, but it's a bit more difficult. For loops, you have to perform the loop yourself, executing that block of code in every pass.

Most loops are easy, only IF..ELSE..ENDIF and DO CASE..CASE..OTHERWISE..END CASE are more difficult, because you don't have a single code block, but multiple. After executing one block of code you have to find the corresponding end code, or if the condition doesn't match right from the beginning you have to find the proper block.

Since all of these structures (except for TEXT...ENDTEXT) can be nested, you need a counter that is increased on every occurence of the same keyword, and decreased upon the proper end token.

If speed is an issue, you can precompile it in your own token format, for example in a DBF and save all these jumps as well as the type of this line, the range of the codeblock, etc. This let's you then quickly execute a program.

The only thing that is more difficult is a class definition. I can't think of a simple way to do this in VFP 5, the only possibility would be to parse out every reference in the current line to see whether it refers to a class defined in that program. too much work, IMO. But in VFP 6 you can use the THIS_Access method to capture every method call. I haven't thought about this in detail, but I think this could give you the possibiliy to hook into that process.

Christof

>I am familiar with this technique. The limitation is the inability to perform looping and branching. Is there a way around this limitation?
--
Christof
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform