Page 1 of 1

C++ Update of TDBChart data plot variables failure

Posted: Fri Jul 07, 2006 2:51 pm
by 9346303
While trying to change the designtime settings for a line plot, I used the following code:

//----------------------------------
if (Series1->Count() != 0)
{
// remove all previous data, then lets add the points
Series1->Clear();
}
// ready for new data
Series1->XValues->Order = loNone;
Series1->YValues->Order = loNone;
CPlotData->HeaderLines = 2;
CPlotData->FieldSeparator = ",";
CPlotData->Fields->Clear();
CPlotData->AddField("X",XIdx);
CPlotData->AddField("Y",YIdx);
CPlotData->FileName = SelectFile->FileName;
CPlotData->Load();

The runtime program encounters a runtime error:

raised exception class EAccessViolation with message 'Access violation at address 00407101 in module 'DeltaPress.exe. Read of address 0000004D'.

This look to be a bad pointer reference. The code looks clean from a C point of view but I must be misusing one of the values.

When I "break" at the exception, the following line is highlighted.

DBChart1->SubTitle->Text->Clear();

Update:

I commented all references to SubTitle and the code executes without encountering an exception.

The plot show no data with a single dotted line in the horizonal and vertical axis. The Title is TDBChart which is the default.

I an trying to change the plotting values during runtime using the same ideas I observed during the design time interface.

Any Ideas?

Thanks in advance.

Posted: Fri Jul 07, 2006 3:09 pm
by narcis
Hi scottpj,

This may be because DBChart1->SubTitle->Text doesn't have any line at this moment. You could try using:

Code: Select all

DBChart1->SubTitle->Text[0]="";

Try the fix and get a system error

Posted: Fri Jul 07, 2006 4:03 pm
by 9346303
[C++ Error] TabMethodDlg.cpp(203): E2285 Could not find a match for 'TStrings::operator =(char *)'

which is a basic problem with the default "" format is (char *) type and the SubTitle->Title does not have a method for the "=" operator.

Your attempted example seems to suggest that I only need to create a global variable and set a pointer to the SubTitle instance pointer?! Will try this.

Could not create an instance

Posted: Fri Jul 07, 2006 4:50 pm
by 9346303
Tried to create an instance to TSubTitle MySubTitle. Could not get the approach to work.

Found that TSubTitle example (Chart_SubTitles .cpp and .h) which shows a class based on TBaseForm. This appears to be a strange usage?! Why is it a form.

This causes me to wonder how the DBChart1 instance is formed.
which is Base_DBChart.h(23) as a pointer.

This implies that the internal values must be created using some methods at the instance creation time which is buried in the Delphi code.

I will try to investigate.

[Solved]Misuse of /Bad interface to SetXValue

Posted: Thu Jul 13, 2006 1:26 pm
by 9346303
I Found that a single statement for declaring X and Y works better with out any exceptions.

Series1->AddXY(XValue,YValue ,"",clTeeColor);

Instead of setting each value of X and Y using a separate statements.

Series1->XValue[LoopCnt] = UIValues.V;
Series1->YValue[LoopCnt] = UIValues.V;

The exceptions are caused by the values being evaluated as addresses.

This corruption of memory could explain the problems that I had with the titles. The titles are now where they should be.