I am new to Harbour with bcc7. Have been using the commercial xHarbour for many years.
Is there a difference in using Hash variables between these two languages?
In the code below, if I attempt to call the hash variable directly like an object:
xJson:UserName my app errors out (no exported method), but xJson["UserName"] seems to work o.k.
Am I using the first option above incorrectly?
function Main()
Local hJson := GetEmptyHash()
Local cJson := ""
Local xJson := nil
Local nSymbols := 0
hJson["UserName"] := "bhopp@matrixcomputer.com"
hJson["AuthToken"] := "anbdefghijklmnopqustuvwxyz"
cJson := hb_JsonEncode( hJson,.f. )
MsgInfo( cJson,"Json.Stringify" )
// {"UserName" :"bhopp@matrixcomputer.com"}
nSymbols := hb_JsonDecode( cJson,@xJson )
MsgInfo( Str( nSymbols ),"Number of Symbols processed." )
// nSymbols == 80
MsgInfo( xJson["UserName"] ,"UserName" )
// bhopp@matrixcomputer.com
MsgInfo( xJson["AuthToken"],"AuthToken" )
// abcdefghijklmnopqrstuvwxyz
MsgInfo( hb_hKeyAt(xJson,1) ,"UserName" )
// UserName
MsgInfo( hb_hKeyAt(xJson,2) ,"AuthToken" )
// AuthToken
MsgInfo( xJson:UserName ,"UserName" )
// generates error...
MsgInfo( xJson:AuthToken ,"AuthToken" )
// never gets here...
return nil
Function GetEmptyHash()
Local hHash := Hash()
HSetAACompatibility( hHash, .T. )
HSetCaseMatch( hHash, .F. )
Return hHash
Byron ...