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!
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
As a hack i erase on method ::edit() of xbrowse some lines:
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