FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour About oBrw:AddColumn
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
About oBrw:AddColumn
Posted: Thu Feb 28, 2008 01:50 PM

Hi,
I am trying to browse an array but I have syntax problems using the oBrw:AddColumn method because I always receive an array access error.

This is a sample code that show the problem.
Any ideas about the correct syntax ?

aBrwArray:=array(0,2)
aadd(aBrwArray,{"01","First"})
aadd(aBrwArray,{"02","Second"})

@ 1.5,5 COLUMN BROWSE aObjects[6] OF oWnd SIZE 150, 135
aObjects[6]:SetArray(aBrwArray)

aObjects[6]:AddColumn(TCColumn:New("Num",aObjects[6]:aArray[aObjects[6]:nAt,1],,,,,100))

aObjects[6]:AddColumn(TCColumn:New("Title",aObjects[6]:aArray[aObjects[6]:nAt,2],,,,,100))

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
About oBrw:AddColumn
Posted: Thu Feb 28, 2008 02:11 PM

First line should be: aBrwArray:={}

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
About oBrw:AddColumn
Posted: Thu Feb 28, 2008 02:32 PM

Oops, I made this error writing on the forum.

The problem still remain with aBrwArray:={}

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 1048
Joined: Mon Oct 24, 2005 09:54 AM
About oBrw:AddColumn
Posted: Thu Feb 28, 2008 03:04 PM

Change nAt with nArrayAt!?

Regards,
Günther
---------------------------------
office@byte-one.com
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 08:32 AM

nArrayAt is only available on xbrowse and not on the standard FWH browse.

I made this self contained sample that show the problem

www.softwarexp.co.uk/beta/test.zip

I think the error message due to the addcolumn syntax I used
(I translated it from the tccolumn include file)

Any ideas appreciated.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 09:20 AM
Marco,
Why don't you just create the columns using commands? I think it'd be easier to read and code. If you still want to do it this way, then why don't you use browse commands but compile with /p switch. By comparing your code and the generated .ppo file you should be able to spot what went wrong. e.g.:

Prg
  ADD COLUMN TO ::oBrwOrder ARRAY ELM 1                            ;
      HEADER " No."  LEFT                                    ;
      SIZE oBFont1:nWidth * 7                                ;
      PICT "@!K"                                               ;



Ppo
 ::oBrwOrder:AddColumn( TCColumn():New( If(.F., OemToAnsi(" No."), " No."), {|x| If(Pcount()>0, ::oBrwOrder:aArray[::oBrwOrder:nAt, 1] :=x, ::oBrwOrder:aArray[::oBrwOrder:nAt, 1])}, "@!K",,, Upper("LEFT"), oBFont1:nWidth * 7, .F., .F.,,,, .F. ) )
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 01:30 PM
Hi Marco:

You have several errors in your posted sample, here you are the corrected code
//----------------------------------------------------------------------------//

function Child()


   local oWndChild, oBrw, oFont
   local nI, aTestData
    local aObjects[10]

   DEFINE WINDOW oWndChild MDICHILD OF oWnd ;
     FROM 10, 50 TO 250, 400 PIXEL  COLOR "N/W"

    aBrwArray:={}
    aadd(aBrwArray,{"01","First"})
    aadd(aBrwArray,{"02","Second"})

    @ 1.5,5 COLUMN BROWSE aObjects[6] OF oWndChild SIZE 150, 135
    aObjects[6]:SetArray(aBrwArray)

    aObjects[6]:AddColumn(TCColumn():New("Num",{|x| ;
    If(Pcount()>0, aObjects[6]:aArray[aObjects[6]:nAt, 1] :=x, aObjects[6]:aArray[aObjects[6]:nAt, 1])},,,,,100))
    aObjects[6]:AddColumn(TCColumn():New("Title",{|x| ;
    If(Pcount()>0, aObjects[6]:aArray[aObjects[6]:nAt, 2] :=x, aObjects[6]:aArray[aObjects[6]:nAt, 2])},,,,,100))

   oWndChild:SetControl( aObjects[6] )

   ACTIVATE WINDOW oWndChild


return nil

Regards

Manuel Mercado
manuelmercado at prodigy dot net dot mx
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 05:07 PM

Hi, Manuel,
it runs fine. Thanks.

The only problem is that I try to assign the columns through a for cicle I receive an array access error message.

My code:

for i:=1 to 2

aObjects[6]:AddColumn(TCColumn():New("Num",{|x| ;
If(Pcount()>0, aObjects[6]:aArray[aObjects[6]:nAt, i] :=x, aObjects[6]:aArray[aObjects[6]:nAt, i])},,,,,100))

next

Do you know any solution ?

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 07:03 PM
Marco Turco wrote:The only problem is that I try to assign the columns through a for cicle I receive an array access error message.

Then, what you need is something like this:
function Child()


   local oWndChild, nI, bData, aObjects[ 10], ;
         aTitles := { "Num", "Title" }

   DEFINE WINDOW oWndChild MDICHILD OF oWnd ;
     FROM 10, 50 TO 250, 400 PIXEL  COLOR "N/W"

    aBrwArray:={}
    aadd(aBrwArray,{"01","First"})
    aadd(aBrwArray,{"02","Second"})

    @ 1.5,5 COLUMN BROWSE aObjects[6] OF oWndChild SIZE 150, 135
    aObjects[6]:SetArray(aBrwArray)

    For nI := 1 To Len( aTitles )
      bData := BuildBlock( AObjects[ 6 ], nI )
      aObjects[6]:AddColumn(TCColumn():New( aTitles[ nI ], bData,,,,, 100 ) )
    next

   oWndChild:SetControl( aObjects[6] )

   ACTIVATE WINDOW oWndChild


return nil

//----------------------------------------------------------------------------//
Static Function BuildBlock( oBrw, n )

Return { |x| If( Pcount() > 0, oBrw:aArray[ oBrw:nAt, n ] := x, oBrw:aArray[ oBrw:nAt, n ] ) }

Regards

Manuel Mercado
manuelmercado at prodigy dot net dot mx
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 08:06 PM

Great !!! Thanks a lot !!

I never loved the codeblocks..

Could you suggest me what is the correct codeblock code to make also
a column with the progressive number ?

Like the command:

ADD TO oBrw DATA oBrw:nAt()

to explain me better.

:shock:

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 08:53 PM
Marco Turco wrote:Could you suggest me what is the correct codeblock code to make also
a column with the progressive number ?
Like the command:
ADD TO oBrw DATA oBrw:nAt()

Following your same example:

aObjects[6]:AddColumn(TCColumn():New( "", {||aObjects[6]:nAt},,,,, 25 ) )

Regards

Manuel Mercado
manuelmercado at prodigy dot net dot mx
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 09:46 PM

Tried but a Bound Error:Array access appairs.

Any ideas ?

function Child()

local oWndChild, nI, bData, aObjects[ 10], ;
aTitles := { "Num", "Title" }

DEFINE WINDOW oWndChild MDICHILD OF oWnd ;
FROM 10, 50 TO 250, 400 PIXEL COLOR "N/W"

aBrwArray:={} 
aadd(aBrwArray,{"01","First"}) 
aadd(aBrwArray,{"02","Second"})

@ 1.5,5 COLUMN BROWSE aObjects[6] OF oWndChild SIZE 150, 135 
aObjects[6]:SetArray(aBrwArray)

** column with progressive number **
Objects[6]:AddColumn(TCColumn():New( "", {||aObjects[6]:nAt},,,,, 25 ) )

For nI := 1 To Len( aTitles ) 
  bData := BuildBlock( AObjects[ 6 ], nI ) 
  aObjects[6]:AddColumn(TCColumn():New( aTitles[ nI ], bData,,,,, 100 ) ) 
next

oWndChild:SetControl( aObjects[6] )

ACTIVATE WINDOW oWndChild

return nil

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 782
Joined: Wed Dec 19, 2007 07:50 AM
About oBrw:AddColumn
Posted: Fri Feb 29, 2008 11:08 PM
Marco Turco wrote:** column with progressive number **
Objects[6]:AddColumn(TCColumn():New( "", {||aObjects[6]:nAt},,,,, 25 ) )

Should be:
aObjects[6]:AddColumn(TCColumn():New( "", {||aObjects[6]:nAt},,,,, 25 ) )

Regards

Manuel Mercado
manuelmercado at prodigy dot net dot mx
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
About oBrw:AddColumn
Posted: Sat Mar 01, 2008 08:24 AM

Yes. You are right.

I need a glasses !!

Many thanks for your support.

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
About oBrw:AddColumn
Posted: Thu Mar 27, 2008 08:50 PM

Hi,
I have a small problem with bitmaps in the TcBrowse.

Do you know how can I translate:

ADD TO oBrw BITMAP DATA aArray[oBrw:nAt(),1]

in code ?

Best Regards,



Marco Turco

SOFTWARE XP LLP