Is there a way to save arrays & codeblocks to restore them later. I'm trying to save report filters.
Is there a way to save arrays & codeblocks to restore them later. I'm trying to save report filters.
You may use FWH ASave() and ARead() functions:
MemoWrit( "array.txt", ASave( aArray ) )
to load it, later on:
aArray = ARead( MemoRead( "array.txt" ) )
There is no way to save codeblocks to disk files, as local references get lost.
Hi HunterEC
Codeblocks can of course be saved in source form since in that form they are just character strings in a particular format. So if they are entered or generated in source form you can save the source and compile them from that source for use at a later date. If it is an interactive reporting system you are developing my guess is they might well be obtainable in such form.
Check out HB_MacroCompile, HB_VMExecute, &( "{||" + cMacro + "}" )
I should note that this is not a line of coding I have had any call to use to date so my information is largely based on documentation alone.
Happy coding
xProgrammer
An addendum
One could (based on the documentation) actually store the compiled pcode - however this would potentially fail any time that the pcode specification changed and the application was recompiled.
Regards
xProgrammer
local a,b,c,d,e
a := {"a", "b", "c" }
b := { || "quique" }
c := valtoprgexp( a )
d := valtoprgexp( b )
e := &d
wqout( &c )
? eval( e )FUNCTION TestSavedCode()
LOCAL sSavedCode
LOCAL sPCode
PUBLIC sTransfer
sTransfer := "testing saved code"
sSavedCode := MemoRead( "SavedCode.txt" )
// MsgInfo( sSavedCode )
sPCode := HB_MacroCompile( sSavedCode )
// MsgInfo( "About to Execute" )
HB_VMExecute( sPCode )
// MsgInfo( "Done" )
RETURN nilMsgInfo( sTransfer )MsgInfo( DATE() )