FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Question about XBrowse.
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Question about XBrowse.
Posted: Sat Jul 12, 2014 02:30 PM
Hi,

This is my part of code. It uses array in xbrowse.

Code (fw): Select all Collapse
        if ! Empty( oCol := oBrw:oCol( "Colon1_1"+CRLF+"Colon1_2" ) )
          oCol:bStrData := {|o|ALLTRIM(oBrw:aRow[3])+;
            IIF(!EMPTY(oBrw:aRow[4])," "+NTRIM(oBrw:aRow[4]),"")+CRLF+ALLTRIM(oBrw:aRow[5])}
        endif


This is Ok for non-empty array but it gives an error empty arrays.

I have tried to change it like below that should works for only nArrayData is non-empty. But the result is the same. ERROR.

Code (fw): Select all Collapse
        if ! Empty( oCol := oBrw:oCol( "Colon1_1"+CRLF+"Colon1_2" ) )
          oCol:bStrData := {|o|IIF(len(oBrw:aArrayData)>0,ALLTRIM(oBrw:aRow[3])+;
            IIF(!EMPTY(oBrw:aRow[4])," "+NTRIM(oBrw:aRow[4]),"")+CRLF+ALLTRIM(oBrw:aRow[5]),"")}
        endif


How can I handle this problem?

Thanks.
Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Question about XBrowse.
Posted: Sun Jul 13, 2014 03:49 AM
Please use oBrw:bEditValue instead of oBrw:bStrData. You do not have to add any code to check emptiness of the array.

Please try
Code (fw): Select all Collapse
      oCol:bEditValue := {||ALLTRIM(oBrw:aRow[3]) + ;
               IIF(!EMPTY(oBrw:aRow[4])," "+LTRIM(STR(oBrw:aRow[4])),"")+CRLF+ALLTRIM(oBrw:aRow[5])}


Note: Use of bStrData has been deprecated from Mar 2008. (Please see whatsnew.txt). Instead usage of bEditValue was advised.

Usage of bStrData is supported for backward compatibility with legacy applications, but such programs can not avail most of the improvements during the last 6 years.

Here is a working sample:
Code (fw): Select all Collapse
#include "fivewin.ch"
#include "xbrowse.ch"

function Main()

   local oDlg, oCn, oRs, oFont, oCbx, oSay, oDbf, obrw
   local cCode := "  "
   local aData    := {}

   DEFINE FONT oFont NAME "ARIAL" SIZE 0,-16
   DEFINE DIALOG oDlg SIZE 600,300 PIXEL FONT oFont

   @ 30,10 XBROWSE oBrw SIZE -10,-10 pixel OF oDlg ARRAY aData ;
      HEADERS "One", "Two", "Three"+CRLF+"Four" ;
      COLUMNS 1, 2, 4 ;
      CELL LINES NOBORDER FASTEDIT

   WITH OBJECT oBrw
      :nEdittYPEs := 1
      :aCols[ 3 ]:bEditValue := {||ALLTRIM(oBrw:aRow[3]) + ;
               IIF(!EMPTY(oBrw:aRow[4])," "+LTRIM(STR(oBrw:aRow[4])),"")+CRLF+ALLTRIM(oBrw:aRow[5])}

      :nDataLines    := 2
      :nHeaderLines  := 2
      :nStretchCol   := 3
      :CreateFromCode()
   END

   @ 10,10 BUTTON "Add Row" SIZE 70,12 PIXEL OF oDlg ;
      ACTION ( AAdd( aData, { 2, 2, "One", 1, "ok" } ), oBrw:Refresh(), oBrw:SetFocus() )

   ACTIVATE DIALOG oDlg CENTERED

   RELEASE FONT oFont

return nil

Empty browse

Browse after adding a row:
Regards



G. N. Rao.

Hyderabad, India
Posts: 1387
Joined: Fri May 23, 2008 01:33 PM
Re: Question about XBrowse.
Posted: Sun Jul 13, 2014 07:56 AM

Mr. Rao,

Thank you. it is ok now.

I have read before you said this. I have tried to change all bStrData to bEditValue in my apps. But in case dbfcdx, some colons (that is defined by bEditValue) the backslashs () appears and some characters is missing. It could be codepage problem. I use Turkish codepage.

Regards,



Hakan ONEMLI



Harbour & MSVC 2022 & FWH 23.06
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Question about XBrowse.
Posted: Sun Jul 13, 2014 03:38 PM

I suggest we work together to solve the problems with Turkish codepage.
If you can provide a small dbf which can create such problems, let me try with Turkish codepage.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion