FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse how to change bound array
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
xBrowse how to change bound array
Posted: Tue Jul 28, 2009 04:35 PM
On a TAB I would like to show an XBrowse. If I switch from one to the other and I would like to change the ARRAY bound to the xBrowse.
I do it this way but I get an error.
Do I need one xBrowse per folder or could I change the array during runtime.

Thanks in advance
Otto

Code (fw): Select all Collapse
@ 460, 0 TABS oTabs ;                                                                                                                                               
      PROMPTS "&Properties", "&Events" OF oWndlocal PIXEL SIZE 340,200;                                                                                              
      ACTION  If( oTabs:nOption == 1,( oBrw:SetArray( aData,.t.), oBrw:refresh() ),;
      ( oBrw:SetArray( aData2,.t.), oBrw:refresh() )  )


Error occurred at: 07/28/09, 18:37:10
Error description: Error BASE/1081 Argument error: +
Args:
[ 1] = U
[ 2] = N 2

Stack Calls
===========
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:LASTDISPLAYPOS(0)
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:PAINT(0)
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DISPLAY(0)
Called from: .\source\classes\CONTROL.PRG => TXBROWSE:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(0)
Called from: => DIALOGBOXINDIRECT(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(0)
Called from: .\source\function\ERRSYSW.PRG => ERRORDIALOG(0)
Called from: .\source\function\ERRSYSW.PRG => (b)ERRORSYS(0)
Called from: .\source\classes\XBROWSE.PRG => (b)TXBRWCOLUMN:SORTARRAYDATA(0))
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xBrowse how to change bound array
Posted: Tue Jul 28, 2009 07:33 PM

Otto,

Try a sysrefresh() bewteen the setArray() and Refresh(). If that doesn't work, then you may want to try compiling a copy of xBrowse and linking it so you can get line numbers in the error message. This way you can see which line is erroring out.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: xBrowse how to change bound array
Posted: Tue Jul 28, 2009 08:02 PM

Hello James,
thank you for your answer.
The error occurs in this line:
nWidth += ::ColAtPos( nPos++ ):nWidth + COL_SEPARATOR

But maybe I need a special reset command.
The sample with SETRDD() xBrwalia.prg in the samples works well.
I will have a closer look into SETARRAY-method.
Best regards,
Otto

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xBrowse how to change bound array
Posted: Tue Jul 28, 2009 08:34 PM
Otto,

Code (fw): Select all Collapse
Error description: Error BASE/1081 Argument error: +
Args:
[ 1] = U 
[ 2] = N 2

nWidth += ::ColAtPos( nPos++ ):nWidth + COL_SEPARATOR


Hmm, the error message doesn't make sense to me. It seems to be saying there is an error with nPos++, but then it is saying there are two passed parameters, the first of which is undefined. But, there is only one passed parameter...

I would try putting some msgInfo() debugging code into the LastDisplayPos() method to see if you can isolate the problem. Maybe ::ColAtPos( nPos++ ):nWith is nil? You could try msgInfo( ::ColAtPos( 1 ):nWidth).

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: xBrowse how to change bound array
Posted: Tue Jul 28, 2009 08:52 PM
Hello James,
If I change the SetArray -method like this it is working - but I am not aware of the side effects:

Best regards,
Otto

Code (fw): Select all Collapse
 if ::lCreated
   
      if ::nDataType == DATATYPE_ARRAY
     //    if SameArrayStruct( Self, aData )
            
     //       ::aArrayData = aData
      //        ::aCols  := {}
             //return nil
    //           lReset   := .t.
    //     else
    //  ::aCols  := {}
            lReSet   := .t.
  //       endif
      else
         ::ClearBlocks()
         ::aCols  := {}
         lReset   := .t.
      endif
      
      
   endif
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xBrowse how to change bound array
Posted: Tue Jul 28, 2009 09:04 PM

Otto,

It looks like it might be a bug. If Antonio doesn't respond to this thread in a day or two, I would email him with a simple example program that shows the error, along with your solution.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: xBrowse how to change bound array
Posted: Tue Jul 28, 2009 09:17 PM

Hello James,
thank you. I forgot to mention that I am still on 9.01 FWH. Maybe this is resolved in one of the most current releases.
I will download tomorrow the last version an try with this.
Best regards,
Otto

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xBrowse how to change bound array
Posted: Tue Jul 28, 2009 09:29 PM
Otto,

I have a newer version and the code is slightly different. Try this

Code (fw): Select all Collapse
      if ::nDataType == DATATYPE_ARRAY
         if SameArrayStruct( Self, aData )
            ::aArrayData = aData
           // ::= {}
            return nil
         else
            ::aCols  := {}
            lReSet   := .t.
         endif


James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse how to change bound array
Posted: Tue Jul 28, 2009 11:27 PM
Mr Otto
I have a running application with tabs and switching arrays. I implemented it when xbrowse was not so mature.
If I have to rewrite that code now, I might switch browses instead of arrays. I am giving a small sample working application here.
Code (fw): Select all Collapse
#include "FiveWin.Ch"
#include "xbrowse.ch"

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

function Main()

   local oWnd, oPanel, oBar, oTabs
   local aBrw[ 2 ]
   local aData1 := { {1,2,3},{4,5,6},{7,8,9} }
   local aData2 := { {'AA','BB','CC','DD'},{'EE','FF','GG','HH'}, ;
                     {'II','JJ','KK','LL'},{'MM','NN','OO','PP'}}

   DEFINE WINDOW oWnd
   DEFINE BUTTONBAR oBar OF oWnd  2007
   SET MESSAGE OF oWnd to '' 2007

   oPanel   := TPanel():New( ,,,, oWnd )
   oWnd:oClient := oPanel

   @ 0,0 XBROWSE aBrw[ 1 ] OF oPanel ;
      HEADERS 'One', 'Two', 'Three' ;
      ARRAY aData1 AUTOCOLS CELL LINES

   aBrw[ 1 ]:CreateFromCode()

   @ 0,0 XBROWSE aBrw[ 2 ] OF oPanel ;
      HEADERS 'AAAA', 'BBBB', 'CCCC' ;
      ARRAY aData2 AUTOCOLS CELL LINES

   aBrw[ 2 ]:CreateFromCode()
   aBrw[ 2 ]:Hide()

   oPanel:oClient := aBrw[ 1 ]

   @ 400,0 TABS oTabs PROMPTS 'First', 'Second' OF oPanel ;
      ON CHANGE ChangeBrw( nOption, nOldOption, aBrw )

   oPanel:oBottom := oTabs

   ACTIVATE WINDOW oWnd

return ( 0 )

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

static function ChangeBrw( nNew, nOld, aBrw )

   aBrw[ nOld ]:Hide()
   aBrw[ nNew ]:oWnd:oClient := aBrw[ nNew ]
   aBrw[ nNew ]:Enable()
   aBrw[ nNew ]:Show()
   aBrw[ nNew ]:oWnd:Resize()

return nil

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

Switching browses has many advantages over switching arrays.
1. You are XBrowse version independant.
2. Different browses can have different datasources, like arrays, dbfs, recordsets
3. Browse states are preserved when switching

Note: I used TPanel because I want to have both message bar and tabs also. If you don't need message bar, you don't have to have TPanel. You can straight away create the browses in the window itself instead of in the Panel
Regards



G. N. Rao.

Hyderabad, India
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: xBrowse how to change bound array
Posted: Wed Jul 29, 2009 07:05 AM

Hello Mr. Rao,
Thank you for your help.
I too use xbrowse the same way you suggest especially if I mix listbox and xbrowse on different Tabs of a folder.
Only I saw that xBrwalia.prg lets you switch between different dbf-files I tried to do it with Arrays but with no success.
I compared the SETRDD and the SETARRAY method and found out commenting out some lines of the SETARRAY method you can get it working.

Coming from the 286MHz and 16-64 k RAM times I still have in mind to use as less objects an code as possible.

Best regards,
Otto

Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: xBrowse how to change bound array
Posted: Wed Jul 29, 2009 07:45 AM
Otto,

to change the array of a xbrowse I use

Code (fw): Select all Collapse
::oBrw:aArrayData := ::aNewArray
::oBrw:Refresh()
kind regards

Stefan
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: xBrowse how to change bound array
Posted: Wed Jul 29, 2009 08:12 AM

Hello Stefan,
thank you so much. Your code is working for me.
Best regards,
Otto

Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse how to change bound array
Posted: Wed Jul 29, 2009 09:23 AM
Mr Otto
I compared the SETRDD and the SETARRAY method and found out commenting out some lines of the SETARRAY method you can get it working.

Then let me too try it. When I tested with the above two arrays in my example, it worked well. ( Because the two arrays did not have the same structure)
Can i have sample of the two array structures you tried to switch and got error ? i would like to experiment too
Regards



G. N. Rao.

Hyderabad, India
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: xBrowse how to change bound array
Posted: Wed Jul 29, 2009 11:04 AM
Dear Mr.Otto,

This code is working for me

Code (fw): Select all Collapse
oBrwMenu:aArrayData:=aMenu
oBrwMenu:Update()
oBrwMenu:Refresh()


Contents of the second xBrowse (right hand side) changes when the user scrolls thru the xBrowse on the left hand side. Array data is used in the right hand side xBrowse and its array data contents are changed dynamically.


Regards
Anser
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse how to change bound array
Posted: Wed Jul 29, 2009 01:02 PM

Mr Anser

The point is that the promised behavior of SetArray is giving errors. If so that need to be rectified by FWH.
It is true we can achieve the objective in some other ways.
The promised behavior is that at run time we can change the datasource from any to any.
If there are bugs in this feature, they have an opportunity to rectify in next releases, if we can point our the problem precisely

Regards



G. N. Rao.

Hyderabad, India