XBROWSE bEditValid bug? updated!

XBROWSE bEditValid bug? updated!

Postby byte-one » Tue Jan 15, 2019 10:27 am

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.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: XBROWSE bEditValid bug? updated!

Postby nageswaragunupudi » Wed Jan 16, 2019 1:54 pm

Working correctly for me.
This is my test program:
Code: Select all  Expand view
  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. } )
 

Image
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10247
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBROWSE bEditValid bug? updated!

Postby byte-one » Wed Jan 16, 2019 2:28 pm

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.
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: XBROWSE bEditValid bug? updated!

Postby byte-one » Wed Jan 16, 2019 3:49 pm

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  Expand view
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  Expand view
//         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
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: XBROWSE bEditValid bug? updated!

Postby byte-one » Thu Jan 17, 2019 11:11 pm

Mr. Rao, please see to my last post!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: XBROWSE bEditValid bug? updated!

Postby byte-one » Tue Feb 12, 2019 11:30 am

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!
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 69 guests