When i use a variable in column 4 with the value "0101" and edit the column the resulting len of the x is 10, not 4!
oBrw:aCols[4]:bEditValid := {|x|msginfo("'"+Eval( x:bSetGet)+"'"+CRLF+"Len: "+alltrim(str(len(Eval( x:bSetGet))))),.T.}
It seems, that the variable always are added with spaces to len min 10 (maybe a UTF-problem). On normal gets outside xbrowse i have not tested.
A second bug:
if :lAutosave := .T. for this column, the bEditValue is evaluated twice if i leave the column with ENTER but when leaving with mouse sometime runtime-error nLastkey == NIL.
XBROWSE bEditValid bug? updated!
- nageswaragunupudi
- Posts: 8017
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Contact:
Re: XBROWSE bEditValid bug? updated!
Working correctly for me.
This is my test program:
This is my test program:
Code: Select all
local aData := { { "one", "0101" }, { "two", "0202" } }
XBROWSER aData FASTEDIT SETUP ( ;
oBrw:aCols[ 2 ]:cEditPicture := "@R 99-99", ;
oBrw:aCols[ 2 ]:bEditValid := { |oGet,c| c := oGet:VarGet(), ;
MsgInfo( Len( c ), c ), .t. } )
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
Re: XBROWSE bEditValid bug? updated!
Thanks, what are the difference between oGet:varget() and eval( oGet:bSetGet) ?
The second bug is definitive!
if :lAutosave := .T. for this column, the bEditValue is evaluated twice if i leave the column with ENTER but when leaving with mouse sometime runtime-error nLastkey == NIL.
The second bug is definitive!
if :lAutosave := .T. for this column, the bEditValue is evaluated twice if i leave the column with ENTER but when leaving with mouse sometime runtime-error nLastkey == NIL.
Re: XBROWSE bEditValid bug? updated!
I make a test-program to show the problem:
If you leave a column the program the ::bEditValid show the variable and the len of the variable.
1. On the first browse the data-array are build at init of the dialog. All columns are now interpreted as wide.
2. On the second browse the data-array are build before the browse is defined. Now all columns are ok except the empty column with space(8). This column are wide.
This breaks the backward-compatibility!
As a hack i erase on method ::edit() of xbrowse some lines:
If you leave a column the program the ::bEditValid show the variable and the len of the variable.
1. On the first browse the data-array are build at init of the dialog. All columns are now interpreted as wide.
2. On the second browse the data-array are build before the browse is defined. Now all columns are ok except the empty column with space(8). This column are wide.
This breaks the backward-compatibility!
Code: Select all
function test_browse()
local oDlg, i
local oBrw1, aArray1 := {}, bAdd1 := {||aadd(aArray1,{1,"01012019",space(8),"0101",space(70),space(70)})}
local oBrw2, aArray2 := {{1,"01012019",space(8),"0101",space(70),space(70)}}
DEFINE DIALOG oDlg SIZE 800,390 PIXEL TITLE "XBROWSE Test"
@ 10, 10 COLUMN XBROWSE oBrw1 OF oDlg ARRAY aArray1 ;
COLS {1,2,3,4,5,6} ;
HEADERS {"Nr","Date1","Date2","Day","Text1","Text2"} ;
JUSTIFY {AL_CENTER,AL_CENTER,AL_CENTER,AL_CENTER} ;
SIZES {30,70,70,70,250} ;
PICTURE {,"@R 99.99.9999","@R 99.99.9999","@R ##.##."} ;
PIXEL;
FASTEDIT;
SIZE oDlg:nWidth()/2-20,oDlg:nHeight()/6
for i = 2 to len(oBrw1:aCols)
oBrw1:aCols[i]:nEdittype := EDIT_GET
oBrw1:aCols[i]:lAutosave := .T.
oBrw1:aCols[i]:bEditValid := {|x|msginfo("'"+x:varget()+"'"+CRLF+"Len: "+alltrim(str(len(x:varget())))),.T.}
// oBrw1:aCols[i]:bonPostedit := {|o,x|msginfo("'"+x+"'"+CRLF+"Len: "+alltrim(str(len(x))))}
next
oBrw1:createfromcode()
@ oBrw1:nBottom+20, 10 COLUMN XBROWSE oBrw2 OF oDlg ARRAY aArray2 ;
COLS {1,2,3,4,5,6} ;
HEADERS {"Nr","Date1","Date2","Day","Text1","Text2"} ;
JUSTIFY {AL_CENTER,AL_CENTER,AL_CENTER,AL_CENTER} ;
SIZES {30,70,70,70,250} ;
PICTURE {,"@R 99.99.9999","@R 99.99.9999","@R ##.##."} ;
PIXEL;
FASTEDIT;
SIZE oDlg:nWidth()/2-20,oDlg:nHeight()/6
for i = 2 to len(oBrw2:aCols)
oBrw2:aCols[i]:nEdittype := EDIT_GET
oBrw2:aCols[i]:lAutosave := .T.
oBrw2:aCols[i]:bEditValid := {|x|msginfo("'"+x:varget()+"'"+CRLF+"Len: "+alltrim(str(len(x:varget())))),.T.}
// oBrw2:aCols[i]:bonPostedit := {|o,x|msginfo("'"+x+"'"+CRLF+"Len: "+alltrim(str(len(x))))}
next
oBrw2:createfromcode()
ACTIVATE DIALOG oDlg ON INIT eval(bAdd1)
return NIL
Code: Select all
// if ValType( uValue ) == "C" .and. ::nDataLen != nil .and. ::nDataLen > ( nLen := Len( uValue ) )
// bSetGet := { |x| If( x == nil, FW_UTF8PADCHAR( uValue, ::nDataLen ), ;
// uValue := FW_UTF8PADCHAR( x, nLen, ::nDataLen ) ) }
// else
bSetGet := { |x| If( x == nil, uValue, uValue := x ) }
// endif
Re: XBROWSE bEditValid bug? updated!
Mr. Rao, please see to my last post!
Re: XBROWSE bEditValid bug? updated!
Mr. Rao have you tested my last testprogram?
And a question for this behavoir: The value from ::nDataLen comes from what method? It seems the value are padded to this lenght but i will keep the original lenght!
And a question for this behavoir: The value from ::nDataLen comes from what method? It seems the value are padded to this lenght but i will keep the original lenght!