About oBrw:AddColumn

About oBrw:AddColumn

Postby Marco Turco » Thu Feb 28, 2008 1: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby byte-one » Thu Feb 28, 2008 2:11 pm

First line should be: aBrwArray:={}
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Postby Marco Turco » Thu Feb 28, 2008 2:32 pm

Oops, I made this error writing on the forum.

The problem still remain with aBrwArray:={}
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby byte-one » Thu Feb 28, 2008 3:04 pm

Change nAt with nArrayAt!?
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Postby Marco Turco » Fri Feb 29, 2008 8: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby hua » Fri Feb 29, 2008 9: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
Code: Select all  Expand view  RUN
  ADD COLUMN TO ::oBrwOrder ARRAY ELM 1                            ;
      HEADER " No."  LEFT                                    ;
      SIZE oBFont1:nWidth * 7                                ;
      PICT "@!K"                                               ;



Ppo
Code: Select all  Expand view  RUN
::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. ) )
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Postby mmercado » Fri Feb 29, 2008 1:30 pm

Hi Marco:

You have several errors in your posted sample, here you are the corrected code
Code: Select all  Expand view  RUN
//----------------------------------------------------------------------------//

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
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Postby Marco Turco » Fri Feb 29, 2008 5: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby mmercado » Fri Feb 29, 2008 7: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:
Code: Select all  Expand view  RUN
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
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Postby Marco Turco » Fri Feb 29, 2008 8:06 pm

Great !!! Thanks a lot !!
:shock: 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.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby mmercado » Fri Feb 29, 2008 8: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
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Postby Marco Turco » Fri Feb 29, 2008 9: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby mmercado » 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
User avatar
mmercado
 
Posts: 782
Joined: Wed Dec 19, 2007 7:50 am
Location: Salamanca, Gto., México

Postby Marco Turco » Sat Mar 01, 2008 8:24 am

Yes. You are right.

I need a glasses !!

Many thanks for your support.
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Postby Marco Turco » Thu Mar 27, 2008 8: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
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: dutch, Otto and 60 guests