Page 1 of 1
xbrowse and detached variables Mr Rao please Help
Posted: Fri Aug 19, 2022 5:13 pm
by wilsongamboa
good afternoon to all
the code don't work as expected for EDIT_LISTBOX
What are bad on the code ?
please help me
Code: Select all | Expand
#include 'fivewin.ch'
#include 'xbrowse.ch'
function main()
local aKeys := {'pichincha','internacio'}
local hBancos := { => }
local hRow
local aCols := {}
local oWnd
local oBrw
local i
local oCol1
local cDbf := '.\test1.dbf'
local aDbf := { { 'codigo' , 'C', 10, 0 } ,;
{ 'pichincha' , 'C', 15, 0 } ,;
{ 'internacio' , 'C', 15, 0 } }
hBancos ['pichincha'] = {}
hRow = { 'numcuenta' => '1234567' }
aadd( hBancos ['pichincha'], hRow )
hBancos ['internacio'] = {}
hRow = { 'numcuenta' => '890123' }
aadd( hBancos ['internacio'], hRow )
dbcreate( cDbf, aDbf )
use ( cDbf ) new alias camello exclusive
camello->( dbappend() )
camello->codigo = '1'
camello->( dbappend() )
camello->codigo = '2'
camello->( dbgotop() )
DEFINE WINDOW oWnd
@ 0,0 XBROWSE oBrw OF oWnd alias 'camello' fastedit
oCol1 := oBrw:AddCol()
oCol1:bEditValue := { || ( oBrw:cAlias )->codigo }
oCol1:cHeader := "codigo"
oCol1:cEditPicture:= "@!"
oCol1:nEditType := 0
oCol1:nWidth := 90
aCols = {}
for i = 1 to len( aKeys )
aadd( aCols, oBrw:AddCol() )
campotexto( oBrw, i+1, @aCols, i, hBancos, aKeys )
next
oBrw:CreateFromCode()
ACTIVATE WINDOW oWnd
return nil
function campotexto( oBrw, i, aCols, n, hBancos, aKeys )
local xValue
local uRet
local c
local aRow
local aEditListTxt
local aEditListBound
local j
local hRow
aRow = hBancos[ aKeys[n] ]
aEditListTxt = {}
aEditListBound = {}
for j = 1 to len( aRow )
hRow = aRow[j]
aadd( aEditListTxt , hRow['numcuenta'] )
aadd( aEditListBound, hRow['numcuenta'] )
next
c = alltrim( lower( ( oBrw:cAlias )->( fieldname( i ) ) ) )
aCols[ n ]:bEditValue := { || ( oBrw:cAlias )->&( c ) }
aCols[ n ]:cHeader := c
aCols[ n ]:cEditPicture := "@!"
aCols[ n ]:nEditType := EDIT_LISTBOX
aCols[ n ]:nWidth := 120
aCols[ n ]:aEditListTxt := aEditListTxt
aCols[ n ]:aEditListBound := aEditListBound
aCols[ n ]:bOnPostEdit := { |o,v| ( oBrw:cAlias )->&( c ) := v }
return uRet
best regards
Wilson
Re: xbrowse and detached variables Mr Rao please Help
Posted: Sun Aug 21, 2022 7:50 am
by Marc Venken
Wilson,
I'm not shure what your code is all doing, but it seems to be that you do things that Xbrowse can do automaticaly.
This sample uses the edit listbox and is easy, but different from your setup. Maybe It can help you.
Code: Select all | Expand
function xbtest()
local aStates
local oDlg, oBrw, oFont
RDDSETDEFAULT( "DBFCDX" )
//aDbf := DIRECTORY( "c:\fwpic\*.jpg" )
USE STATES SHARED
aStates := FW_DbfToArray()
CLOSE STATES
/*
Now aStates is 2-dimentional array.
1st column is State Code
2nd column is State name
Customer.dbf has a field "STATE". This is State Code
We want to display State Name in the browse listbox
When user selects a State Name, we want to store State Code in the DBF
XBrowse does this automatically
PLEASE NEVER NEVER USE BONPOSTEDIT(). This is depricated many years back.
*/
USE CUSTOMER SHARED
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 700,400 PIXEL TRUEPIXEL FONT oFont
@ 20,20 XBROWSE oBrw SIZE -20,-20 PIXEL OF oDlg ;
DATASOURCE "CUSTOMER" ;
COLUMNS "First", "City", "State" ;
CELL LINES NOBORDER FASTEDIT
WITH OBJECT oBrw
:nEditTypes := EDIT_GET
WITH OBJECT :State
:nEditType := EDIT_LISTBOX
:aEditListTxt := aStates
END
//
:CreateFromCode()
END
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil
and here some code that I use as a kind off standard setup :
Code: Select all | Expand
local aGroepen:={ "BEDRIJVEN","ZELFSTANDI","VERENIGING","SCHOOLTURN","SCHOOLTECH","SCHOOLZORG","SCHOLEN","HORECA","GEMEENTEN","INSTELLING"}
aVelden := { ;
{ "email" , "Email" ,nil, 150 }, ; // 7
{ "klantcode" , "Klant" ,nil, 45 }, ; // 1
{ "naam" , "Naam" ,nil, 100 }, ; // 1
{ "Groep" , "Groep" ,nil, 95 }, ; // 4
// here was more ....
{ "optout" , "Optout" ,nil, 50 }, ; // 1
{ "mail005" , "M5" ,nil, 30 }, ; // 6
{ "mail006" , "M6" ,nil, 30 }, ; // 6
{ "mail007" , "M7" ,nil, 30 }} // 19
@ 70,10 XBROWSE oBrw size 1400,500 PIXEL OF oDlg font oFont ;
DATASOURCE "mailbulk";
COLUMNS aVelden;
AUTOSORT CELL LINES NOBORDER FOOTERS
//FASTEDIT
oBrw:nEditTypes = EDIT_GET
oBrw:lF2KeyToEdit := .t. // Edit when F2 is pressed
oBrw:bRClickHeaders := { || XbrColSelector( oBrw ) }
oBrw:SetChecks()
oBrw:bKeyDown := {|nkey| iif(nkey=VK_ADD, iif(oBrw:sel:VALUE=.t.,oBrw:sel:VarPut( .F. ),oBrw:sel:VarPut( .t. )) ,)}
oBrw:bron:bClrStd := { || showcolors(oBrw:bron:Value) }
for n := 1 to Len( oBrw:aCols )
WITH OBJECT oBrw:aCols[ n ]
if :cDataType != 'L'
:uBarGetVal := uValBlank( :Value )
:cBarGetPic := :cEditPicture
endif
END
next
WITH OBJECT oBrw
WITH OBJECT:Groep
:nEditType := EDIT_LISTBOX
:aEditListTxt := aGroepen
END
:SetGroupHeader( "Mailings", oBrw:oCol("M1"):nCreationOrder, oBrw:oCol("M7"):nCreationOrder )
:bRClicked := {|nRow, nCol| MenuPop( nRow,nCol, oBrw ),oBrw:refresh() }
:nFreeze:=4
:lSeekbar := .T.
:lFooter := .t.
:email:bFooter := { | oCol | Len( oBrw:aSelected ) }
:bRecSelHeader := { || "RowNo" }
:bRecSelData := { |o| o:KeyNo }
:bRecSelFooter := { |o| o:nLen }
:oRecSelFont := oFont // optional
:nRecSelWidth := "999999" // required size
//:SetGroupHeader( 'Omzet', 5, 6, oBold )
//:SetGroupHeader( 'Aanmaningen', 9, 11, oBold )
//:nStretchCol := 10
//:lDisplayZeros := .f.
//:nStretchCol := 4
:bClrEdits := { || { CLR_BLACK, CLR_YELLOW }}
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:nColDividerStyle := LINESTYLE_LIGHTGRAY
:nRowDividerStyle := LINESTYLE_LIGHTGRAY
:bClrRowFocus := { || { CLR_BLACK, RGB(185,220,255) } }
:nMarqueeStyle := MARQSTYLE_HIGHLROWMS
//:lIncrFilter := .t.
//:lSeekWild := ( nWild == 2 )
//:cFilterFld := "naam"
//:bFooters := { |oCol| If( Empty( oCol:cOrder ), "", oBrw:cSeek("") ) }
//:oSeek := TSeek():New( oBrw )
END
BrwBarBtns( oBar, oBrw )
oBrw:CreateFromCode()
Re: xbrowse and detached variables Mr Rao please Help
Posted: Sun Aug 21, 2022 9:11 am
by Antonio Linares
Dear Marc,
Thank you so much for your help
I have added your example to FWH provided examples as marc.prg
Re: xbrowse and detached variables Mr Rao please Help
Posted: Sun Aug 21, 2022 7:02 pm
by wilsongamboa
Dear Marc many thanks for your help
but unfortunately does;n solve my problem
I prepare better example if I don't use detached locals work Well like the column tipo_docu1
In real life we need fields like pichincha an internatio as a result of data driven code because may have 2 columns or 3 or more columns and need an listbox asociatted to every column but xbrowse don't work this kind of column but work well in ocol4 column as your example
Code: Select all | Expand
#include 'fivewin.ch'
#include 'xbrowse.ch'
function main()
local aKeys := {'pichincha','internacio'}
local hBancos := { => }
local hRow
local aCols := {}
local oWnd
local oBrw
local i
local oCol1
local oCol4
local cDbf := '.\test1.dbf'
local aDbf := { { 'codigo' , 'C', 10, 0 } ,;
{ 'pichincha' , 'C', 15, 0 } ,;
{ 'internacio' , 'C', 15, 0 } ,;
{ 'tipo_docu1' , 'C', 02, 0 } }
hBancos ['pichincha'] = {}
hRow = { 'numcuenta' => '1234567' }
aadd( hBancos ['pichincha'], hRow )
hBancos ['internacio'] = {}
hRow = { 'numcuenta' => '890123' }
aadd( hBancos ['internacio'], hRow )
dbcreate( cDbf, aDbf )
use ( cDbf ) new alias camello exclusive
camello->( dbappend() )
camello->codigo = '1'
camello->( dbappend() )
camello->codigo = '2'
camello->( dbgotop() )
DEFINE WINDOW oWnd
@ 0,0 XBROWSE oBrw OF oWnd alias 'camello' fastedit
oCol1 := oBrw:AddCol()
oCol1:bEditValue := { || ( oBrw:cAlias )->codigo }
oCol1:cHeader := "codigo"
oCol1:cEditPicture:= "@!"
oCol1:nEditType := 0
oCol1:nWidth := 90
aCols = {}
for i = 1 to len( aKeys )
aadd( aCols, oBrw:AddCol() )
campotexto( oBrw, i+1, @aCols, i, hBancos, aKeys )
next
oCol4 := oBrw:AddCol()
oCol4:bEditValue := { || ( oBrw:cAlias )->tipo_docu1 }
oCol4:cHeader := "Tipo1"
oCol4:cEditPicture := "@!"
oCol4:nEditType := EDIT_LISTBOX
oCol4:nWidth := 80
oCol4:aEditListTxt := {'deposito','anticipo'}
oCol4:aEditListBound := {'DP','AN'}
oCol4:bOnPostEdit := { |o,v| ( oBrw:cAlias )->tipo_docu1 := v }
//oBrw:nEditTypes := EDIT_GET
oBrw:CreateFromCode()
ACTIVATE WINDOW oWnd
return nil
function campotexto( oBrw, i, aCols, n, hBancos, aKeys )
local xValue
local uRet
local c
local aRow
local aEditListTxt
local aEditListBound
local j
local hRow
aRow = hBancos[ aKeys[n] ]
aEditListTxt = {}
aEditListBound = {}
for j = 1 to len( aRow )
hRow = aRow[j]
aadd( aEditListTxt , { hRow['numcuenta'], hRow['numcuenta'] } )
aadd( aEditListBound, { hRow['numcuenta'], hRow['numcuenta'] } )
next
c = alltrim( lower( ( oBrw:cAlias )->( fieldname( i ) ) ) )
aCols[ n ]:bEditValue := { || ( oBrw:cAlias )->&( c ) }
aCols[ n ]:cHeader := c
aCols[ n ]:cEditPicture := "@!"
aCols[ n ]:nEditType := EDIT_LISTBOX
aCols[ n ]:nWidth := 120
aCols[ n ]:aEditListTxt := aEditListTxt
//aCols[ n ]:bOnPostEdit := { |o,v| ( oBrw:cAlias )->&( c ) := v }
return uRet
Many Thanks for your time and help
Re: xbrowse and detached variables Mr Rao please Help
Posted: Mon Aug 22, 2022 5:32 pm
by nageswaragunupudi
Mr. Wilson
I see your point.
Please let me know the FWH version you are using.
Re: xbrowse and detached variables Mr Rao please Help
Posted: Mon Aug 22, 2022 9:15 pm
by Cgallegoa
Hi Mr. Rao
I have version FWH 20.07 with the same and other problems in xBrowse. Is there a corrected version of xBrowse for FWH 20.07 ?
Thanks for your help,
Regards,
Re: xbrowse and detached variables Mr Rao please Help
Posted: Mon Aug 22, 2022 10:06 pm
by wilsongamboa
dear master
Code: Select all | Expand
┌────────────────────────────────────────────────────────────────────────────┐
│ FiveWin for Harbour 19.09 - Sep. 2019 Harbour development power │▄
│ (c) FiveTech 1993-2019 for Microsoft Windows 9X/NT/200X/ME/XP/Vista/7/8/10 │█
└────────────────────────────────────────────────────────────────────────────┘█
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
Compiling...
Harbour 3.2.0dev (r1909261630)
Copyright (c) 1999-2019, https://harbour.github.io/
Compiling 'xbrowse.prg' and generating preprocessed output to 'xbrowse.ppo'...
Lines 5333, Functions/Procedures 2
Generating C source output to 'xbrowse.c'... Done.
Embarcadero C++ 7.00 for Win32 Copyright (c) 1993-2015 Embarcadero Technologies,
Inc.
xbrowse.c:
Turbo Incremental Link 6.70 Copyright (c) 1997-2014 Embarcadero Technologies, In
c.
Fatal: Could not open xbrowse.exe (program still running?)
many thanks for your time
regards
Wilson
Re: xbrowse and detached variables Mr Rao please Help
Posted: Thu Aug 25, 2022 4:50 pm
by wilsongamboa
Dear Master Rao, any News ?
best regards
Wilson
Re: xbrowse and detached variables Mr Rao please Help
Posted: Thu Aug 25, 2022 6:35 pm
by Antonio Linares
Estimado Wilson,
Le acabo de escribir al Sr. Rao para que lo revise cuanto antes.
Te pedimos disculpas por el retraso
Re: xbrowse and detached variables Mr Rao please Help
Posted: Thu Aug 25, 2022 7:37 pm
by wilsongamboa
Gracias Antonio en verdad estoy necesitando ese tema para terminar un proyecto
saludos
Re: xbrowse and detached variables Mr Rao please Help
Posted: Fri Aug 26, 2022 12:18 pm
by nageswaragunupudi
Mr. Wilson
Please try this sample and let me know if it serves your purpose.
Code: Select all | Expand
#include 'fivewin.ch'
function main()
local aKeys := {'pichincha','internacio'}
local hBancos := { => }
local hRow
local aCols := {}
local oWnd
local oBrw
local i
local oCol1
local cDbf := '.\test1.dbf'
local aDbf := { { 'codigo' , 'C', 10, 0 } ,;
{ 'pichincha' , 'C', 15, 0 } ,;
{ 'internacio' , 'C', 15, 0 } }
hBancos ['pichincha'] = {}
hRow = { 'numcuenta' => '1234567' }
aadd( hBancos ['pichincha'], hRow )
hBancos ['internacio'] = {}
hRow = { 'numcuenta' => '890123' }
aadd( hBancos ['internacio'], hRow )
dbcreate( cDbf, aDbf )
use ( cDbf ) new alias camello exclusive
camello->( dbappend() )
camello->codigo = '1'
camello->( dbappend() )
camello->codigo = '2'
camello->( dbgotop() )
// REVISED CODE BEGIN
//-------------------
aCols := { "codigo" }
AEval( aKeys, { |c| AAdd( aCols, c ) } )
DEFINE WINDOW oWnd
@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE "CAMELLO" ;
COLUMNS aCols FASTEDIT
WITH OBJECT oBrw
for i := 1 to 2
WITH OBJECT oBrw:aCols[ i + 1 ]
:nWidth := 120
:nEditType := EDIT_LISTBOX
:aEditListTxt := {}
AEval( hBancos[ :cExpr ], { |hRow| AAdd( :aEditListTxt, hRow['numcuenta'] ) } )
END
next
:CreateFromCode()
END
ACTIVATE WINDOW oWnd CENTERED
return nil
Re: xbrowse and detached variables Mr Rao please Help
Posted: Fri Aug 26, 2022 12:19 pm
by nageswaragunupudi
Cgallegoa wrote:Hi Mr. Rao
I have version FWH 20.07 with the same and other problems in xBrowse. Is there a corrected version of xBrowse for FWH 20.07 ?
Thanks for your help,
Regards,
Can you please let me know your other problems?
Re: xbrowse and detached variables Mr Rao please Help
Posted: Fri Aug 26, 2022 2:16 pm
by nageswaragunupudi
Mr. Wilson
Your way of creating columns using oBrw:AddCol()
Code: Select all | Expand
#include 'fivewin.ch'
function main()
local aKeys := {'pichincha','internacio'}
local hBancos := { => }
local hRow
local aCols := {}
local oWnd
local oBrw
local i
local oCol1
local cDbf := '.\test1.dbf'
local aDbf := { { 'codigo' , 'C', 10, 0 } ,;
{ 'pichincha' , 'C', 15, 0 } ,;
{ 'internacio' , 'C', 15, 0 } }
hBancos ['pichincha'] = {}
hRow = { 'numcuenta' => '1234567' }
aadd( hBancos ['pichincha'], hRow )
hBancos ['internacio'] = {}
hRow = { 'numcuenta' => '890123' }
aadd( hBancos ['internacio'], hRow )
dbcreate( cDbf, aDbf )
use ( cDbf ) new alias camello exclusive
camello->( dbappend() )
camello->codigo = '1'
camello->( dbappend() )
camello->codigo = '2'
camello->( dbgotop() )
DEFINE WINDOW oWnd
@ 0,0 XBROWSE oBrw OF oWnd alias 'camello' fastedit
oCol1 := oBrw:AddCol()
oCol1:bEditValue := { || ( oBrw:cAlias )->codigo }
oCol1:cHeader := "codigo"
oCol1:cEditPicture:= "@!"
oCol1:nEditType := 0
oCol1:nWidth := 90
for i = 1 to len( aKeys )
CreateColumn( oBrw, aKeys[ i ], hBancos )
next
oBrw:CreateFromCode()
ACTIVATE WINDOW oWnd
return nil
function CreateColumn( oBrw, cField, hBancos )
local oCol, nFld
WITH OBJECT ( oCol := oBrw:AddCol() )
nFld := ( oBrw:cAlias )->( FieldPos( cField ) )
:cHeader := cField
:cExpr := cField
:bEditValue := { || FieldGet( nFld ) }
:bOnPostEdit := { |o,x,n| If( n == VK_ESCAPE,,( oBrw:cAlias )->( FieldPut( nFld, x ) ) ) }
:cEditPicture := "@!"
:nWidth := 120
:nEditType := EDIT_LISTBOX
:aEditListTxt := {}
AEval( hBancos[ cField ], { |hRow| AAdd( :aEditListTxt, hRow[ "numcuenta" ] ) } )
END
return oCol
Please try this also.
Re: xbrowse and detached variables Mr Rao please Help
Posted: Fri Aug 26, 2022 2:35 pm
by nageswaragunupudi
Using fieldname macro, instead of FieldPut() and FieldGet() as in the sample you posted.
Code: Select all | Expand
#include 'fivewin.ch'
function main()
local aKeys := {'pichincha','internacio'}
local hBancos := { => }
local hRow
local aCols := {}
local oWnd
local oBrw
local i
local oCol1
local cDbf := '.\test1.dbf'
local aDbf := { { 'codigo' , 'C', 10, 0 } ,;
{ 'pichincha' , 'C', 15, 0 } ,;
{ 'internacio' , 'C', 15, 0 } }
hBancos ['pichincha'] = {}
hRow = { 'numcuenta' => '1234567' }
aadd( hBancos ['pichincha'], hRow )
hBancos ['internacio'] = {}
hRow = { 'numcuenta' => '890123' }
aadd( hBancos ['internacio'], hRow )
dbcreate( cDbf, aDbf )
use ( cDbf ) new alias camello exclusive
camello->( dbappend() )
camello->codigo = '1'
camello->( dbappend() )
camello->codigo = '2'
camello->( dbgotop() )
DEFINE WINDOW oWnd
@ 0,0 XBROWSE oBrw OF oWnd alias 'camello' fastedit
oCol1 := oBrw:AddCol()
oCol1:bEditValue := { || ( oBrw:cAlias )->codigo }
oCol1:cHeader := "codigo"
oCol1:cEditPicture:= "@!"
oCol1:nEditType := 0
oCol1:nWidth := 90
for i = 1 to len( aKeys )
CreateColumn( oBrw, aKeys[ i ], hBancos )
next
oBrw:CreateFromCode()
ACTIVATE WINDOW oWnd
return nil
function CreateColumn( oBrw, cField, hBancos )
local oCol
WITH OBJECT ( oCol := oBrw:AddCol() )
:cHeader := cField
:cExpr := cField
:bEditValue := { || &( cField ) }
:bOnPostEdit := { |o,x,n| If( n == VK_ESCAPE,,( oBrw:cAlias )->&( cField ) := x ) }
:cEditPicture := "@!"
:nWidth := 120
:nEditType := EDIT_LISTBOX
:aEditListTxt := {}
AEval( hBancos[ cField ], { |hRow| AAdd( :aEditListTxt, hRow[ "numcuenta" ] ) } )
END
return oCol
Re: xbrowse and detached variables Mr Rao please Help
Posted: Sat Aug 27, 2022 1:47 am
by wilsongamboa
Dear Master Rao
Hats Off !!!!!!!!!!!!!!!
all works fine
Many many thanks !!!
The code exceed my knowledge but xbrowse is great !!
I'll Continue with my project
Again
Many Thnaks
best regards
Wilson