Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run code from memo field using compiled .EXE (Fox 6)

Status
Not open for further replies.

mcoupal

Technical User
Jul 9, 2001
61
US
I have a program where a certain section of code will need to change frequently. The code includes CASE statements and could not be run on a line-by-line method using macro statements stored in a table's field. I figured I could store the code in a memo field and execute it. However, I'm unsure how to do this when running from a compiled .EXE.

I have seen this sample code:
copy memo DoIt to MyTemp.Prg
comp MyTemp.prg
do MyTemp

However, I don't believe this will work from a compiled project (.EXE). At least, I'm getting a "Feature Not Available" error.

Any idea?
TIA
 
As long as the code is not dynamically generated, you should be able to store the compiled part (the .FXP file) in the memo field instead of the text part. Then you can just copy the memo field to a file and execute it. Assuming the code you provided works, perhaps try this instead:
Code:
copy memo DoIt to MyTemp.FXP
do MyTemp
This is how procedures are stored for form files, so I imagine it would work...never tried it myself, but I HAVE executed a .FXP file that no longer had the corresponding .PRG file and it worked just fine.
 
By the way, I just ran a little test on my theory and was able to get it to work. Here were the steps I took:

1) Create a .PRG file with the code you need.
2) Compile the .PRG file.
3) Run another .PRG file which reads the .FXP file byte by byte and stores it into a memo field in a table.

At this point, I now have a memo field with the compiled code. Now, you just need to change the lines as I stated above. I tested this in a compiled .EXE file, and it worked properly.
 
You can dynamically generate the code, the Foxpro runtime libraries will generate the .FXP from the .PRG if it (the .FXP) does not exist at runtime. One caveat, you should delete the .FXP before you generate a new .PRG. Foxpro looks for .FXP first an will not 'check' the latest .PRG when you issue a do command.
 
Yes, the FoxPro libraries will generate the .FXP...in the development environment. It will NOT do so from within a compiled .EXE file, though. It will give the (misleading) error: File 'MyProg.prg' does not exist.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top