xBrowse con HASH
xBrowse con HASH
Hola a todos,
Es posible hacer un xBrowse con una array de Hash como elementos ?
Muchas Gracias.
Pere Cordonet
Es posible hacer un xBrowse con una array de Hash como elementos ?
Muchas Gracias.
Pere Cordonet
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: xBrowse con HASH
Yes.
We can browse a Hash or Array of Hashes.
Browing a Hash ( xHarbour & FWH 10.2 )
Result:
Alternative code:
Browsing Array of Hashes:
Result:
We can browse a Hash or Array of Hashes.
Browing a Hash ( xHarbour & FWH 10.2 )
Code: Select all
#include "FiveWin.Ch"
#include "xbrowse.ch"
function Main()
local h := {=>}
h:Age := 45
h:City := 'NewYork'
h:JoinDt := {^ 1997/12/21}
h:First := 'John'
h:Last := 'Abraham'
XBROWSER h
return ( 0 )
Alternative code:
Code: Select all
#include "FiveWin.Ch"
#include "xbrowse.ch"
function Main()
local oDlg, oBrw
local h := {=>}
h:Age := 45
h:City := 'NewYork'
h:JoinDt := {^ 1997/12/21}
h:First := 'John'
h:Last := 'Abraham'
DEFINE DIALOG oDlg
@ 5,5 XBROWSE oBrw SIZE -5,-5 PIXEL OF oDlg ;
ARRAY h AUTOCOLS HEADERS 'Detail', 'Value' ;
CELL LINES NOBORDER
oBrw:nStretchCol := 1
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
return ( 0 )
Code: Select all
#include "FiveWin.Ch"
#include "xbrowse.ch"
//------------------------------------------------------------------//
function Main()
local oDlg, oBrw, oFont
local aHash := {}, h
AAdd( aHash, {=>} )
h := ATail( aHash )
h:Age := 45
h:City := 'NewYork'
h:JoinDt := {^ 1997/12/21}
h:First := 'John'
h:Last := 'Abraham'
AAdd( aHash, {=>} )
h := ATail( aHash )
h:Age := 30
h:City := 'Boston'
h:JoinDt := {^ 1990/10/02}
h:First := 'Adam'
h:Last := 'Brian'
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE DIALOG oDlg SIZE 350,200 PIXEL FONT oFont
@ 5,5 XBROWSE oBrw SIZE -5,-5 PIXEL OF oDlg ;
ARRAY aHash AUTOCOLS ;
CELL LINES NOBORDER
oBrw:nStretchCol := STRETCHCOL_LAST
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return ( 0 )
//------------------------------------------------------------------//
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: xBrowse con HASH
Hello nageswaragunupudi
Can you post one sample of array of hashes.
Many, many thanks.
Pere
Can you post one sample of array of hashes.
Many, many thanks.
Pere
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: xBrowse con HASH
I have just edited the above posting to include code to browse array of hashespcordonet wrote:Hello nageswaragunupudi
Can you post one sample of array of hashes.
Many, many thanks.
Pere
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: xBrowse con HASH
Work fine.
Thank you.
Pere
Thank you.
Pere
- Marcelo Roggeri
- Posts: 275
- Joined: Sat Jul 22, 2006 9:04 pm
- Location: Venado Tuerto - Santa Fe -Argentina
- Contact:
Re: xBrowse con HASH
Hola Rao buenos dias, estoy queriendo implementar las tablas Hash viendo tu ejemplo, al compilar me da el siguiente error
Agradezco si puedes ayudarme, gracias de antemano
Saludos
Marcelo
Code: Select all
Time from start: 0 hours 0 mins 0 secs
Error occurred at: 08/26/18, 10:12:23
Error description: Error BASE/1005 No exported variable: AGE
Args:
[ 1] = H {=>}
[ 2] = N 45
Stack Calls
===========
Called from: => _AGE( 0 )
Called from: HASH6.prg => MAIN( 13 )
Code: Select all
#include "FiveWin.Ch"
#include "xbrowse.ch"
//------------------------------------------------------------------//
function Main()
local oDlg, oBrw, oFont
local aHash := {}, h
AAdd( aHash, {=>} )
h := ATail( aHash )
h:Age := 45
h:City := 'NewYork'
h:JoinDt := {^ 1997/12/21}
h:First := 'John'
h:Last := 'Abraham'
AAdd( aHash, {=>} )
h := ATail( aHash )
h:Age := 30
h:City := 'Boston'
h:JoinDt := {^ 1990/10/02}
h:First := 'Adam'
h:Last := 'Brian'
DEFINE FONT oFont NAME 'TAHOMA' SIZE 0,-12
DEFINE DIALOG oDlg SIZE 350,200 PIXEL FONT oFont
@ 5,5 XBROWSE oBrw SIZE -5,-5 PIXEL OF oDlg ;
ARRAY aHash AUTOCOLS ;
CELL LINES NOBORDER
oBrw:nStretchCol := STRETCHCOL_LAST
oBrw:CreateFromCode()
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return ( 0 )
//------------------------------------------------------------------//
Saludos
Marcelo
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: xBrowse con HASH
The syntax
h:Age
works only with xHarbour.
This syntax works with both Harbour and xHarbour:
h[ "Age" ]
h:Age
works only with xHarbour.
This syntax works with both Harbour and xHarbour:
h[ "Age" ]
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- Marcelo Roggeri
- Posts: 275
- Joined: Sat Jul 22, 2006 9:04 pm
- Location: Venado Tuerto - Santa Fe -Argentina
- Contact:
Re: xBrowse con HASH
Muchas gracias Rao
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)
- Marcelo Roggeri
- Posts: 275
- Joined: Sat Jul 22, 2006 9:04 pm
- Location: Venado Tuerto - Santa Fe -Argentina
- Contact:
Re: xBrowse con HASH
Hola Rao, abusando un poco de tu buena predisposicion, estoy haciendo un facturador y en los itema de la factura agrego los articulos, y quiero implementarlo usando hash.
Como hago en xBrowse para referenciar a una columna del hash, por ejemplo idProducto
Pego parte del codigo
Como hago en xBrowse para referenciar a una columna del hash, por ejemplo idProducto
Pego parte del codigo
Code: Select all
oBrwItem := TXBrowse():New( oPanelDetL )
*-----------------------------------------------
oCol := oBrwItem:AddCol()
oCol:cHeader := "I.D."
oCol:nWidth := 80
oCol:bStrData := {||If( Len( oBrwItem:aArrayData ) > 0, oBrwItem:aArrayData[ oBrwItem:nArrayAt, 1 ], "" )} // con array
oCol:bStrData := {||If( Len( oBrwItem:aArrayData ) > 0, oBrwItem:aArrayData[ oBrwItem:nArrayAt, 1 ], "" )} // con array
oCol:cDataType := "N"
*-----------------------------------------------
oCol := oBrwItem:AddCol()
oCol:cHeader := "Descripción del Producto"
oCol:nWidth := 250
oCol:cDataType := "C"
oCol:bStrData := { || oQry:DescripcionProducto } // con un query
*-----------------------------------------------
oBrwItem:SetArray( aHash )
AAdd( aHash, {=>} )
h := ATail( aHash )
h["IdProducto"] := hVarArt["nIdProducto"]
h["NombreProducto"] := hVarArt["cNomPro"]
h["CodigoProducto"] := hVarArt["cCodPro"]
h["Cantidad"] := 1
h["PrecioUnitarioNeto"] := hVarArt["nPreUni"]
h["ImporteNetoItem"] := hVarArt["nPreUni"]
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)
- Marcelo Roggeri
- Posts: 275
- Joined: Sat Jul 22, 2006 9:04 pm
- Location: Venado Tuerto - Santa Fe -Argentina
- Contact:
Re: xBrowse con HASH
Hola Rao, abusando un poco de tu buena predisposicion, estoy haciendo un facturador y en los itema de la factura agrego los articulos, y quiero implementarlo usando hash.
Como hago en xBrowse para referenciar a una columna del hash, por ejemplo idProducto
Pego parte del codigo
Saludos y gracias
Como hago en xBrowse para referenciar a una columna del hash, por ejemplo idProducto
Pego parte del codigo
Code: Select all
oBrwItem := TXBrowse():New( oPanelDetL )
*-----------------------------------------------
oCol := oBrwItem:AddCol()
oCol:cHeader := "I.D."
oCol:nWidth := 80
oCol:bStrData := {||If( Len( oBrwItem:aArrayData ) > 0, oBrwItem:aArrayData[ oBrwItem:nArrayAt, 1 ], "" )} // con array
oCol:bStrData := {|| } // con hash?
oCol:cDataType := "N"
*-----------------------------------------------
oCol := oBrwItem:AddCol()
oCol:cHeader := "Descripción del Producto"
oCol:nWidth := 250
oCol:cDataType := "C"
oCol:bStrData := { || oQry:DescripcionProducto } // con un query
oCol:bStrData := {|| } // con hash?
*-----------------------------------------------
oBrwItem:SetArray( aHash )
AAdd( aHash, {=>} )
h := ATail( aHash )
h["IdProducto"] := hVarArt["nIdProducto"]
h["NombreProducto"] := hVarArt["cNomPro"]
h["CodigoProducto"] := hVarArt["cCodPro"]
h["Cantidad"] := 1
h["PrecioUnitarioNeto"] := hVarArt["nPreUni"]
h["ImporteNetoItem"] := hVarArt["nPreUni"]
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)
- Marcelo Roggeri
- Posts: 275
- Joined: Sat Jul 22, 2006 9:04 pm
- Location: Venado Tuerto - Santa Fe -Argentina
- Contact:
Re: xBrowse con HASH
Rao, revisando la clase de xBrowse, creo que es asi:
y me lo muestra bien, lo que quiero saber si esta bien asi o puedo reducir el codigo un poco
Gracias de antemano
Saludos
Code: Select all
oCol:bStrData := {|| if(Len( aHash ) > 0 .and. ValType( aHash[ 1 ] ) == 'H', aHash[1]["IdProducto"] ,"" ) }
Gracias de antemano
Saludos
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)
- Marcelo Roggeri
- Posts: 275
- Joined: Sat Jul 22, 2006 9:04 pm
- Location: Venado Tuerto - Santa Fe -Argentina
- Contact:
Re: xBrowse con HASH
asi quedo finalmente
Saludos
Code: Select all
oCol:bStrData := {|| if(Len( aHash ) > 0 .and. ValType( aHash[ 1 ] ) == 'H', aHash[oBrwItem:nArrayAt]["IdProducto"] ,"" ) }
FWH - Harbour - BCC7 - PellesC - FivEdit (Cristobal Navarro)