Error on Header of Xbrowse

Error on Header of Xbrowse

Postby Silvio.Falconi » Thu Sep 29, 2022 7:20 pm

Dear Friends

In reference to the message posted on the forum, I tried the example sent to me by Cesar Gomez that you can see on the forum and the test works fine, when I copied the test on my application I only changed instead of a dialog I use a wndchild window , the array creates fine but I can't get the function that creates the headers and group headers to work



I have created a small test that uses a child window to show you what the problem is

Initially I open the lotto.dbf file and create a filter because I want to view only the records of a specific year, for example 2022

   
Code: Select all  Expand view
oQry := TDatabase():Open( , cdbfPath+"LOTTO", "DBFCDX", .T. )
    oQry:setorder(1)  //index to data field
         cFilter:= "LTRIM(STR(YEAR(FIELD->DATA)))= '" + nyear + "'"
        oQry:SetFilter(cFilter)
        oQry:GoTop()


later I'm going to create the array

   
Code: Select all  Expand view
  aArray := Build_Array(oQry)



I create the window with the xbrowse and I go to write the headers

Code: Select all  Expand view
 Build_Title(oQry,oBrw,val(nRecnos))



at this point it gives an error that I do not understand in the file error.log where the error is


   Error occurred at: 29/09/2022, 20:10:48
   Error description: Error BASE/1081  Argument error: +
   Args:
     [   1] = N   2
     [   2] = U  

Stack Calls
===========
   Called from: .\source\classes\XBROWSE.PRG => TXBRWCOLUMN:PAINTHEADER( 14000 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINTHEADER( 2825 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT( 2350 )
   Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY( 2166 )



the test
Code: Select all  Expand view
#include "fivewin.ch"

REQUEST DBFCDX

static oWndMain, oWndlotto

//----------------------------------------------------------------------------//

function Main()

   local oBrush, oFont



   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12


   DEFINE WINDOW oWndMain TITLE "Test xbrowse lotto" MDI MENU BuildMenu() VSCROLL HSCROLL
   oWndMain:SetFont( oFont )

   BuildMainBar()

   DEFINE MSGBAR PROMPT "lotto win" ;
                 OF oWndMain 2007 KEYBOARD DATE

   ACTIVATE WINDOW oWndMain MAXIMIZED


return nil

//----------------------------------------------------------------------------//

INIT PROCEDURE inv_init

   SET DATE ITALIAN
   SET CENTURY ON
   SET EPOCH TO ( YEAR( DATE() ) - 50 )

   RDDSETDEFAULT( "DBFCDX" )
   SET DELETED ON

   SetGetColorFocus()

return

//----------------------------------------------------------------------------//
 static function BuildMainBar()

   local oBar

   DEFINE BUTTONBAR oBar OF oWndMain 2007 SIZE 70, 60 //70
 return nil

//----------------------------------------------------------------------------//

static function BuildMenu()

   local oMenu

   MENU oMenu

      MENUITEM "Tasks"
      MENU
         MENUITEM "lotto" ACTION lotto()
         SEPARATOR
         MENUITEM "Exit" ACTION oWndMain:End()
      ENDMENU



   ENDMENU

return oMenu

//----------------------------------------------------------------------------//
  static function lotto()

   local oBrw, aArray := {} ,oMsgBar
   local oBar,oQry
   local cdbfPath :=".\data\"
   local nyear:="
2022"
   local cfilter
   local aRecno := {"
2","3","5","10","20","30","40","50","100","200","300","500"}
   local oCom, nRecnos := "
2", i, oCol

    oQry := TDatabase():Open( , cdbfPath+"
LOTTO", "DBFCDX", .T. )
    oQry:setorder(1)  //data

    cFilter:= "
LTRIM(STR(YEAR(FIELD->DATA)))= '" + nyear + "'"
        oQry:SetFilter(cFilter)
        oQry:GoTop()

      aArray := Build_Array(oQry)




   if oWndlotto == nil
      DEFINE WINDOW oWndlotto MDICHILD OF oWndMain TITLE "
lotto"

      oBar  := BrwBtnBar( @oBrw, oWndlotto )


        @ 05, 300 COMBOBOX oCom VAR nRecnos ITEMS aRecno SIZE 90,60 PIXEL of oBar;
    ON CHANGE (oBrw:ResetBrowse(),;
               aArray := Build_Array(oQry,val(nRecnos)),;
               oBrw:SetArray(aArray),;
               Build_Title(oQry,oBrw,val(nRecnos)),;
               aEval(oBrw:aCols,{|o| o:nWidth   := 17}),;
               oBrw:aCols[1]:nWidth:= 60,;
               oBrw:aCols[1]:cHeader := "
Ruote",;
               SetupBrowselotto(oBrw,val(nRecnos)),;
               oBrw:Refresh())





       @ 2, 0 XBROWSE oBrw OF oWndlotto LINES AUTOSORT ;
         AUTOCOLS DATASOURCE aArray NOBORDER









     WITH OBJECT oBrw
         :CreateFromCode()
      END


      Build_Title(oQry,oBrw,val(nRecnos))

   SetupBrowselotto(oBrw,val(nRecnos))




      oWndlotto:oClient = oBrw
      oWndlotto:oControl = oBrw

      DEFINE MSGBAR oMsgBar OF oWndlotto 2007

      ACTIVATE WINDOW oWndlotto MAXIMIZED ;
         VALID ( oWndlotto := nil, .T. )
   else
      oWndlotto:SetFocus()
   endif

return nil

//---------------------------------------------------------//


  static function BrwBtnBar( oBrw, oWnd )

   local oBar

   DEFINE BUTTONBAR oBar OF oWnd 2007 SIZE 70, 60 //70





return oBar




static function  Build_Array(oDbf,n)
   local aTemp:= {}, i, nIni
   local aRuote  := {"
Bari","Cagliari","Firenze","Genova",;
                   "
Milano","Napoli","Palermo","Roma","Torino",;
                   "
Venezia","Nazionale"}

   local cTitle

   default n := 0


  FOR i:= 1 TO 11
      AaDd(aTemp, {aRuote[i]})
  NEXT i
  oDbf:GoTop()

   i := 1
  do while !oDbf:Eof
    AaDd(aTemp[1],oDbf:ba1)
    AaDd(aTemp[1],oDbf:ba2)
    AaDd(aTemp[1],oDbf:ba3)
    AaDd(aTemp[1],oDbf:ba4)
    AaDd(aTemp[1],oDbf:ba5)
    AaDd(aTemp[2],oDbf:ca1)
    AaDd(aTemp[2],oDbf:ca2)
    AaDd(aTemp[2],oDbf:ca3)
    AaDd(aTemp[2],oDbf:ca4)
    AaDd(aTemp[2],oDbf:ca5)
    AaDd(aTemp[3],oDbf:fi1)
    AaDd(aTemp[3],oDbf:fi2)
    AaDd(aTemp[3],oDbf:fi3)
    AaDd(aTemp[3],oDbf:fi4)
    AaDd(aTemp[3],oDbf:fi5)
    AaDd(aTemp[4],oDbf:ge1)
    AaDd(aTemp[4],oDbf:ge2)
    AaDd(aTemp[4],oDbf:ge3)
    AaDd(aTemp[4],oDbf:ge4)
    AaDd(aTemp[4],oDbf:ge5)
    AaDd(aTemp[5],oDbf:mi1)
    AaDd(aTemp[5],oDbf:mi2)
    AaDd(aTemp[5],oDbf:mi3)
    AaDd(aTemp[5],oDbf:mi4)
    AaDd(aTemp[5],oDbf:mi5)
    AaDd(aTemp[6],oDbf:na1)
    AaDd(aTemp[6],oDbf:na2)
    AaDd(aTemp[6],oDbf:na3)
    AaDd(aTemp[6],oDbf:na4)
    AaDd(aTemp[6],oDbf:na5)
    AaDd(aTemp[7],oDbf:pa1)
    AaDd(aTemp[7],oDbf:pa2)
    AaDd(aTemp[7],oDbf:pa3)
    AaDd(aTemp[7],oDbf:pa4)
    AaDd(aTemp[7],oDbf:pa5)
    AaDd(aTemp[8],oDbf:rm1)
    AaDd(aTemp[8],oDbf:rm2)
    AaDd(aTemp[8],oDbf:rm3)
    AaDd(aTemp[8],oDbf:rm4)
    AaDd(aTemp[8],oDbf:rm5)
    AaDd(aTemp[9],oDbf:to1)
    AaDd(aTemp[9],oDbf:to2)
    AaDd(aTemp[9],oDbf:to3)
    AaDd(aTemp[9],oDbf:to4)
    AaDd(aTemp[9],oDbf:to5)
    AaDd(aTemp[10],oDbf:ve1)
    AaDd(aTemp[10],oDbf:ve2)
    AaDd(aTemp[10],oDbf:ve3)
    AaDd(aTemp[10],oDbf:ve4)
    AaDd(aTemp[10],oDbf:ve5)
    AaDd(aTemp[11],oDbf:nz1)
    AaDd(aTemp[11],oDbf:nz2)
    AaDd(aTemp[11],oDbf:nz3)
    AaDd(aTemp[11],oDbf:nz4)
    AaDd(aTemp[11],oDbf:nz5)
    oDbf:Skip()

    if i >= n .and. n > 0
       exit
    endif
    i++
  enddo

  //oBrw:setarray(aTemp)

RETURN aTemp
//-----------------------------------------------------------//
static function  Build_Title(oDbf,oBrw,n)
  local nIni := 2   , i
  local cTitle


   default n := 0
   i := 1

   oDbf:GoTop()
  do while !oDbf:Eof()
    oBrw:aCols[nIni]:cHeader := "
1"
    oBrw:aCols[nIni+1]:cHeader := "
2"
    oBrw:aCols[nIni+2]:cHeader := "
3"
    oBrw:aCols[nIni+3]:cHeader := "
4"
    oBrw:aCols[nIni+4]:cHeader := "
5"
    cTitle:= CF(oDbf:data)
    oBrw:SetGroupHeader( cTitle, nIni, nIni+4 )
    oDbf:Skip()

      if i >= n .and. n > 0
       exit
    endif
    i++
    nIni := nIni +5
  enddo
RETURN NIL
//---------------------------------------------------------------//

Function SetupBrowselotto(oBrw,nrecnos)

    WITH OBJECT oBrw
                      :nRowHeight    := 30
                      :nClrBorder := CLR_GRAY
                      :nMarqueeStyle       := MARQSTYLE_HIGHLROWMS
                      :lHscroll            := .t.
                      :l2007               := .F.
                      :l2015               := .T.
                     // :nStretchCol         := STRETCHCOL_WIDEST
                      :lAllowRowSizing     := .F.
                      :lAllowColSwapping   := .F.
                      :lAllowColHiding     := .F.
                      :lRecordSelector     := .F.
                      :nColDividerStyle    := LINESTYLE_LIGHTGRAY
                      :nRowDividerStyle    := LINESTYLE_LIGHTGRAY

              oBrw:aCols[1]:cHeader := "
Ruote"


      FOR i := 2 TO LEN(:aCols)
         oCol := :aCols[ i ]
         oCol:nWidth   := 17
      NEXT

       FOR i := 1 TO 1
             oCol := :aCols[ i ]
             oCol:nWidth   := 60
             oCol:nColDividerStyle    := LINESTYLE_BLACK
             oCol:bClrStd := {|| { CLR_WHITE, RGB(255,0,0) } }
          NEXT

           IF nRecnos > 5
             FOR i := 1 TO nRecnos  STEP 5
             oCol := :aCols[ i ]
             oCol:nColDividerStyle    := LINESTYLE_BLACK
            NEXT
         Endif

      END

      Return nil





    FUNCTION Cf(dTemp)
   LOCAL Meses:="
GenFebMarAprMagGiuLugAgoSetOttNovDic"
   LOCAL f, m, cMes, dFech
   f:=DTOS (dTemp)
   m:=MONTH(dTemp)
   cMes:=IF(m<>0,SubStr(Meses,(m*3)-2,3),"
")
   dFech:=IF(m<>0,SubStr(f,7,2)+'-'+cMes+'-'+SubStr(f,1,4),'')
   RETURN (dFech)





How I can resolve ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Error on Header of Xbrowse

Postby Silvio.Falconi » Fri Sep 30, 2022 9:27 am

If you change this


Code: Select all  Expand view
static function  Build_Title(oDbf,oBrw,n)
  local nIni := 2   , i
  local cTitle


   default n := 0
   i := 1

   oDbf:GoTop()
  do while !oDbf:Eof()
    oBrw:aCols[nIni]:cHeader := "1"
    oBrw:aCols[nIni+1]:cHeader := "2"
    oBrw:aCols[nIni+2]:cHeader := "3"
    oBrw:aCols[nIni+3]:cHeader := "4"
    oBrw:aCols[nIni+4]:cHeader := "5"
    cTitle:= CF(oDbf:data)
    //  oBrw:SetGroupHeader( cTitle, nIni, nIni+4 )

    AEval( oBrw:aCols, { |o| o:cGrpHdr := cTitle  }, nIni, nIni+4 )
    oDbf:Skip()

      if i >= n .and. n > 0
       exit
    endif
    i++
    nIni := nIni +5
  enddo
RETURN NIL



Make not the error but I can show this


Image
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm

Re: Error on Header of Xbrowse

Postby Silvio.Falconi » Fri Sep 30, 2022 10:00 am

With
AEval( oBrw:aCols, { |o| o:cGrpHdr := cTitle }, nIni, nIni+4 )
AEval( oBrw:aCols, { |o| o:nGrpHeight := 25 } )


Image


Now Not see the header !!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7052
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Rick Lipkin and 53 guests