Jeff Barnes wrote:Is there a way to have an external file (txt or maybe ini) where I could put code and have my app run that code and return a result?
I want to be able to give my users a way to change a formula that uses data in a dbf file.
Example of external file:
IF TEST->Age > 40
nResult := (TEST->Data1 * TEST->Data2) - (TEST->Data3 / TEST->Data4)
ELSE
nResult := (TEST->Data1 * TEST->Data2) - (TEST->Data3 / TEST->Data4) + 500
ENDIF
Jefff try tihis:
In your application:
/* ***************************************** */
FUNCTION ExeFile( )
Local cFile := "MyAMPA32.prg"
Local nRespuesta := 0
Local ureturn := Nil
If File (cFile )
If File ( "MyAMPA32.hrb" )
HB_HRBRun( "MyAMPA32.hrb", @ureturn )
Else
If (nRespuesta := HB_Compile( "", cFile, "-n", "-gh" ) ) == 0
HB_HRBRun( "MyAMPA32.hrb", @ureturn )
EndIf
EndIf
EndIf
msgalert( ureturn, "ssss" )
Return nRespuesta
/* ***************************************** */
Your external PRG:
/* ***************************************** */
FUNCTION MyAMPA32( uReturn )
uReturn := Date() + 5
RETURN uReturn - 3
/* ***************************************** */
If you changes the external file, you must delete the "MyAMPA32.hrb" file.
For this you must add the lib "hbcplr.lib"
Regards,