Hi,Everyone
Sometime, I want to automate create some codes in runtime and put them into
a temp file (such as temp.prg),and compile project into a exe file, if
execute such exe file which includes these codes in vfp environment, it
works well. but if I execute such exe file solely, it always comes a error
message indicate that there is a error in line 7. The following is my
example:

&& A edit object is in thisform named edit1
&& A command object is in thisform named cmd1, caption:execute
&& Those codes what I want pc to do is write in edit1 object


In Click event of Cmd1
I put such code in it:

LOCAL TempCurs,tmpDir,RetVal,ErrMessage
TempCurs=SYS(2015)
RetVal=ALLTRIM(ThisForm.Edit1.Value)
STRTOFILE(RetVal,ADDBS(GETENV("Temp"))+TempCurs+'.prg')
TRY
Do (ADDBS(GETENV("Temp"))+TempCurs+'.prg')
CATCH TO ErrMessage
MESSAGEBOX(ErrMessage.Message+"ÔÚ(µÚ"+TRANSFORM(ErrMessage.LineNo)+"
ÐÐ)",0,"Çë×¢Òâ!")
FINALLY
ENDTRY

No Matter what code I put into thisform.edit1.value, it will always come a
error message.
Anyone can tell me the reason?

Tks In Advance!

Chuen

Re: Why I can't execute prg file in Runtime? by Eric

Eric
Wed May 19 05:44:26 CDT 2004

Hello, Chuen!

If I am not mistaken, you have to COMPILE the prg first and run the fxp.
Perhaps a better alternative for you is to use EXECSCRIPT() which takes care
of all this stuff for you:

RetVal=EXECSCRIPT(ThisForm.Edit1.Value)

See VFP help for more info on EXECSCRIPT().
--
Eric den Doop
www.foxite.com - The Home Of The Visual FoxPro Experts - Powered By VFP8



Re: Why I can't execute prg file in Runtime? by Chuen

Chuen
Wed May 19 07:56:09 CDT 2004

It seems ok, thank you!

"Chuen" <cnchuen@hotmail.com> дÈëÓʼþ
news:uK5LS0YPEHA.3020@tk2msftngp13.phx.gbl...
> Hi,Everyone
> Sometime, I want to automate create some codes in runtime and put them
into
> a temp file (such as temp.prg),and compile project into a exe file, if
> execute such exe file which includes these codes in vfp environment, it
> works well. but if I execute such exe file solely, it always comes a error
> message indicate that there is a error in line 7. The following is my
> example:
>
> && A edit object is in thisform named edit1
> && A command object is in thisform named cmd1, caption:execute
> && Those codes what I want pc to do is write in edit1 object
>
>
> In Click event of Cmd1
> I put such code in it:
>
> LOCAL TempCurs,tmpDir,RetVal,ErrMessage
> TempCurs=SYS(2015)
> RetVal=ALLTRIM(ThisForm.Edit1.Value)
> STRTOFILE(RetVal,ADDBS(GETENV("Temp"))+TempCurs+'.prg')
> TRY
> Do (ADDBS(GETENV("Temp"))+TempCurs+'.prg')
> CATCH TO ErrMessage
> MESSAGEBOX(ErrMessage.Message+"ÔÚ(µÚ"+TRANSFORM(ErrMessage.LineNo)+"
> ÐÐ)",0,"Çë×¢Òâ!")
> FINALLY
> ENDTRY
>
> No Matter what code I put into thisform.edit1.value, it will always come a
> error message.
> Anyone can tell me the reason?
>
> Tks In Advance!
>
> Chuen
>
>
>
>