C++ Update of TDBChart data plot variables failure

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
scottpj
Newbie
Newbie
Posts: 17
Joined: Mon May 15, 2006 12:00 am

C++ Update of TDBChart data plot variables failure

Post by scottpj » Fri Jul 07, 2006 2:51 pm

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.
Last edited by scottpj on Fri Jul 07, 2006 3:10 pm, edited 1 time in total.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Jul 07, 2006 3:09 pm

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]="";
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

scottpj
Newbie
Newbie
Posts: 17
Joined: Mon May 15, 2006 12:00 am

Try the fix and get a system error

Post by scottpj » Fri Jul 07, 2006 4:03 pm

[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.

scottpj
Newbie
Newbie
Posts: 17
Joined: Mon May 15, 2006 12:00 am

Could not create an instance

Post by scottpj » Fri Jul 07, 2006 4:50 pm

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.

scottpj
Newbie
Newbie
Posts: 17
Joined: Mon May 15, 2006 12:00 am

[Solved]Misuse of /Bad interface to SetXValue

Post by scottpj » Thu Jul 13, 2006 1:26 pm

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.

Post Reply