Precisei disso essa semana, uma HT que é o retultset do banco e precisava adicionar uma coluna nova nessa HT, usando Hb_HMerge é possível fazer isto, o código abaixo é uma demonstração, para quem usa hashtable segue segue a dica
hTable := {}
FOR I:=1 TO 10
hRecord := Nil
hRecord := {=>}
hRecord["TESTE1"] := I
hRecord["TESTE2"] := STRZERO(I,2)
aAdd( hTable, hRecord )
NEXT
hNewCol := {}
FOR I:=1 TO Len( hTable )
hRecord := {=>}
hRecord["TESTE3"] := .F.
aAdd( hNewCol, hRecord )
NEXT
FOR I:=1 TO Len( hTable )
Hb_HMerge( hTable[i], hNewCol[i] )
NEXT
FOR EACH oElemento IN hTable
? oElemento["TESTE1"], oElemento["TESTE2"], oElemento["TESTE3"]
NEXT
►Harbour 3.x | Minigui xx-x | HwGui◄ Pense nas possibilidades abstraia as dificuldades. Não corrigir nossas falhas é o mesmo que cometer novos erros. A imaginação é mais importante que o conhecimento. (Albert Einstein)
Pelo que entendi... não entendi.
Mas vou tentar entender....
Apenas o detalhe de que é um array com hash table chama atenção.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2) "The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell" https://github.com/JoseQuintas/
PROCEDURE Main
LOCAL hTable := {}, I, oVar, hRecord
FOR I := 1 TO 10
hRecord := Nil
hRecord := {=>}
hRecord[ "TESTE1" ] := I
hRecord[ "TESTE2" ] := STRZERO(I,2)
aAdd( hTable, hRecord )
NEXT
FOR EACH oVar IN hTable
oVar[ "TESTE3" ] := .F. // aqui
NEXT
FOR EACH oVar IN hTable
? oVar[ "TESTE1" ], oVar[ "TESTE2" ], oVar[ "TESTE3" ]
NEXT
Inkey(0)
RETURN
Mas fica a opção do merge, se quiser acrescentar tudo de uma vez, ou vários campos de uma vez.
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2) "The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell" https://github.com/JoseQuintas/
hTable := Array(10)
FOR EACH oVar IN hTable
oVar := {=>}
oVar[ "TESTE1" ] := oVar:__EnumIndex
oVar[ "TESTE2" ] := StrZero( oVar:__EnumIndex, 2 )
NEXT
AEval( hTable, { | e | e[ "TESTE3" ] := .F. } )
FOR EACH oVar IN hTable
? oVar[ "TESTE1" ], oVar[ "TESTE2" ], oVar[ "TESTE3" ]
NEXT
Inkey(0)
RETURN
José M. C. Quintas
Harbour 3.2, mingw, gtwvg mt, fivewin 25.04, multithread, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui mt), (hmg3), (hmg extended), (oohg), PNotepad, ASP, stored procedure, stored function, Linux (Flagship/harbour 3.2) "The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell" https://github.com/JoseQuintas/
JoséQuintas escreveu:Apenas o detalhe de que é um array com hash table chama atenção.
Muito bom os seus exemplos, a questão de ser um array é poder usar aSort da forma que não é array aSort não funciona
Exemplo:
aSort( ::aValorClasse ,,, {|x,y| y["CLASSEVALOR"] > x["CLASSEVALOR"] } )
►Harbour 3.x | Minigui xx-x | HwGui◄ Pense nas possibilidades abstraia as dificuldades. Não corrigir nossas falhas é o mesmo que cometer novos erros. A imaginação é mais importante que o conhecimento. (Albert Einstein)
►Harbour 3.x | Minigui xx-x | HwGui◄ Pense nas possibilidades abstraia as dificuldades. Não corrigir nossas falhas é o mesmo que cometer novos erros. A imaginação é mais importante que o conhecimento. (Albert Einstein)