I have created the following chart function:
function plotArrayDataOrderDet2 as Charting::ChartDataDefinition(linkingFieldValue as n)
'Create an array with some data to plot
dim tbl As P
tbl = Table.open("products",FILE_RO_SHARED)
dim qry as P
dim nrecs as N
query.description = "Filter Products"
query_order = ""
query_filter = "Region="+alltrim(str(Var->DefaultRegion))
query_flags = ""
qry = tbl.query_create(query_flags, query_filter, query_order)
nrecs = qry.records_get()
IF (nrecs = 0) then
qry.drop()
ui_msg_box("Null Query","There are no records in the Query" ,UI_INFORMATION_SYMBOL)
query.order = ""
query.filter = ""
END
end if
dim a[nrecs] as p
dim Counter as N
dim ProdName AS C
dim TestVal As N
Counter = 1
tbl.fetch_first()
while .NOT. tbl.fetch_eof()
if Counter < 100 then 'just for testing!
TestVal = tablesum("orderdetail","Prodnum = "+ alltrim(str(tbl.prodnum)) +".AND.Region = Var->defaultregion.and.BETWEEN(DateToProcess,{" + DTOC(Var->StartDate) + "},{" + DTOC(Var->EndDate) + "})", "DiscountPrice")
if TestVal > Var->VarNum4 then
ProdName = alltrim(str(tbl.prodnum)) '+ ": " + left(tbl.shortdesc,10)
a[Counter].name = ProdName
a[Counter].value = TestVal
'Remember... DiscountPrice, unlike SpecialPrice, has already multiplied the Quantity
Counter = Counter + 1
end if
end if
tbl.fetch_next()
end while
dim count as n
count = a.size()
dim i as n
' Dim the chart & series
dim cd as Charting::ChartDataDefinition
dim cs as Charting::ChartSeriesDefinition
cd.series.add(cs)
for i = 1 to count
dim cdd as Charting::ChartValueDefinition = new Charting::ChartValueDefinition()
cd.value = format_data(a[i].value,",")
cdd.label = a[i].name + " ("+cdd.value+")"
cs.data.add(cdd)
next
plotArrayDataOrderDet2 = cd
qry.drop()
tbl.close()
end function
The function runs for a few seconds then ends with the following error: "Property is write only a[] not found"
The offending line is: cd.value = format_data(a[i].value,",")
How can I fix this?
function plotArrayDataOrderDet2 as Charting::ChartDataDefinition(linkingFieldValue as n)
'Create an array with some data to plot
dim tbl As P
tbl = Table.open("products",FILE_RO_SHARED)
dim qry as P
dim nrecs as N
query.description = "Filter Products"
query_order = ""
query_filter = "Region="+alltrim(str(Var->DefaultRegion))
query_flags = ""
qry = tbl.query_create(query_flags, query_filter, query_order)
nrecs = qry.records_get()
IF (nrecs = 0) then
qry.drop()
ui_msg_box("Null Query","There are no records in the Query" ,UI_INFORMATION_SYMBOL)
query.order = ""
query.filter = ""
END
end if
dim a[nrecs] as p
dim Counter as N
dim ProdName AS C
dim TestVal As N
Counter = 1
tbl.fetch_first()
while .NOT. tbl.fetch_eof()
if Counter < 100 then 'just for testing!
TestVal = tablesum("orderdetail","Prodnum = "+ alltrim(str(tbl.prodnum)) +".AND.Region = Var->defaultregion.and.BETWEEN(DateToProcess,{" + DTOC(Var->StartDate) + "},{" + DTOC(Var->EndDate) + "})", "DiscountPrice")
if TestVal > Var->VarNum4 then
ProdName = alltrim(str(tbl.prodnum)) '+ ": " + left(tbl.shortdesc,10)
a[Counter].name = ProdName
a[Counter].value = TestVal
'Remember... DiscountPrice, unlike SpecialPrice, has already multiplied the Quantity
Counter = Counter + 1
end if
end if
tbl.fetch_next()
end while
dim count as n
count = a.size()
dim i as n
' Dim the chart & series
dim cd as Charting::ChartDataDefinition
dim cs as Charting::ChartSeriesDefinition
cd.series.add(cs)
for i = 1 to count
dim cdd as Charting::ChartValueDefinition = new Charting::ChartValueDefinition()
cd.value = format_data(a[i].value,",")
cdd.label = a[i].name + " ("+cdd.value+")"
cs.data.add(cdd)
next
plotArrayDataOrderDet2 = cd
qry.drop()
tbl.close()
end function
The function runs for a few seconds then ends with the following error: "Property is write only a[] not found"
The offending line is: cd.value = format_data(a[i].value,",")
How can I fix this?
Comment