Hello friends,
Is there a Harbour function to save a HASH to a file and then read it back in.
Best regards,
Otto
Hello friends,
Is there a Harbour function to save a HASH to a file and then read it back in.
Best regards,
Otto
Dear Otto,
good morning
You have to convert the hash into a JSON string using hb_jsonEncode( hTheHash ) --> cJson then you can save it to disk using hb_memoWrit()
to recover the hash from the file you use hb_memoRead() and then call to hb_jsonDecode( cJson, @hTheHash ), simply declare local hTheHash before
local hPost
//memowrit( "c:\www\htdocs\booking_new1\room.txt", hb_jsonencode( hPairs ) )
hb_jsondecode( memoread( "c:\www\htdocs\booking_new1\room.txt" ), @hPost )Dear Antonio,
This is real time support from you.
Thank you very much.
There is no better forum and programming community than this.
Best regards,
Otto
Otto wrote:Dear Antonio,I totally agree!
This is real time support from you.
Thank you very much.
There is no better forum and programming community than this.
HB_MEMOWRIT( cFile, HB_ValToExp( hHash ) )
// Reading back
hHash := &( MEMOREAD( cFile ) )#include "fivewin.ch"
function Main()
local hHash1, hHash2, cJson, cHash
SET DATE GERMAN
SET CENTURY ON
hHash1 := { "date" => Date() }
cJson := hb_jsonEncode( hHash1 )
hb_jsonDecode( cJson, @hHash2 )
? hHash1[ "date" ], ValType( hHash1[ "date" ] ), ;
hHash2[ "date" ], ValType( hHash2[ "date" ] )
hHash1 := { "date" => Date() }
cHash := hb_ValToExp( hHash1 )
hHash2 := &cHash
? hHash1[ "date" ], ValType( hHash1[ "date" ] ), ;
hHash2[ "date" ], ValType( hHash2[ "date" ] )
return nil