xBrowse how to change bound array

xBrowse how to change bound array

Postby Otto » Tue Jul 28, 2009 4: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: Select all  Expand view
@ 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))
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: xBrowse how to change bound array

Postby James Bott » Tue Jul 28, 2009 7: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: xBrowse how to change bound array

Postby Otto » Tue Jul 28, 2009 8: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: xBrowse how to change bound array

Postby James Bott » Tue Jul 28, 2009 8:34 pm

Otto,

Code: Select all  Expand view
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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: xBrowse how to change bound array

Postby Otto » Tue Jul 28, 2009 8: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: Select all  Expand view
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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: xBrowse how to change bound array

Postby James Bott » Tue Jul 28, 2009 9: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: xBrowse how to change bound array

Postby Otto » Tue Jul 28, 2009 9: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: xBrowse how to change bound array

Postby James Bott » Tue Jul 28, 2009 9:29 pm

Otto,

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

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


James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: xBrowse how to change bound array

Postby nageswaragunupudi » 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: Select all  Expand view

#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
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse how to change bound array

Postby Otto » Wed Jul 29, 2009 7: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
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: xBrowse how to change bound array

Postby StefanHaupt » Wed Jul 29, 2009 7:45 am

Otto,

to change the array of a xbrowse I use

Code: Select all  Expand view
::oBrw:aArrayData := ::aNewArray
::oBrw:Refresh()
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: xBrowse how to change bound array

Postby Otto » Wed Jul 29, 2009 8:12 am

Hello Stefan,
thank you so much. Your code is working for me.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6328
Joined: Fri Oct 07, 2005 7:07 pm

Re: xBrowse how to change bound array

Postby nageswaragunupudi » Wed Jul 29, 2009 9: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
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse how to change bound array

Postby anserkk » Wed Jul 29, 2009 11:04 am

Dear Mr.Otto,

This code is working for me

Code: Select all  Expand view
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.
Image

Regards
Anser
User avatar
anserkk
 
Posts: 1332
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: xBrowse how to change bound array

Postby nageswaragunupudi » Wed Jul 29, 2009 1: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
User avatar
nageswaragunupudi
 
Posts: 10625
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 82 guests