About oBrw:AddColumn
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
About oBrw:AddColumn
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))
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
Marco Turco
SOFTWARE XP LLP
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
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.
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
Marco Turco
SOFTWARE XP LLP
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
Ppo
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
ADD COLUMN TO ::oBrwOrder ARRAY ELM 1 ;
HEADER " No." LEFT ;
SIZE oBFont1:nWidth * 7 ;
PICT "@!K" ;
Ppo
Code: Select all
::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. ) )
Hi Marco:
You have several errors in your posted sample, here you are the corrected code
Regards
Manuel Mercado
You have several errors in your posted sample, here you are the corrected code
Code: Select all
//----------------------------------------------------------------------------//
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
Manuel Mercado
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
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 ?
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
Marco Turco
SOFTWARE XP LLP
Then, what you need is something like this: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.
Code: Select all
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 ] ) }
Manuel Mercado
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
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
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
Marco Turco
SOFTWARE XP LLP
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact: