This example based on ComponentWorks samples and NI KB article:
void __fastcall TForm1::ApplyBtnClick(TObject *Sender)
{
Variant XData(OPENARRAY(int,(0,20)),varDouble);
Variant YData(OPENARRAY(int,(0,20)),varDouble);
int i;
double data;
double Amplitude = Edit1->Text.ToDouble();
for(i=0; i<=20; i++)
{
XData.PutElement((double)i,i);
data = Amplitude*sin(i/5.0);
YData.PutElement(data,i);
}
CWGraph1->PlotXvsY((VARIANT)XData,(VARIANT)YData);
}
In Win9x/Me systems this code work fine. I can press 'Apply' button
1-10-100-... times and get correct result.
But in NT-based system in second time I get error message "Invalid variant
operation". Why??? What's wrong in this code?
Error disappears if
I run application from Builder IDE.
P.S. C++ Builder 5 (Upd 1).