Page 1 of 1

dplot dde repeatedly use

Posted: Mon Sep 19, 2005 8:36 am
by Tom Chien
I spent 2 days on this. Still need help.

What I want is to continue plot and save manys through dde. It works to me one by one but not on loop. It promps "Error Processing This Command/ [Activate[2]" for loop more thane one. I did try to check status "Ready" or "Busy". It alway "Ready" in this case.
[code]
DocNum = dPlot_Command(0, "[FileNew(3)]");
for (i = 0; i < 1; i++) {

//read input data here .......

dPlot_AddData(DocNum, DATA_3DR, 900, 1, X, X);
dPlot_Command(DocNum,"[GenerateMesh119,119,0,0,29,29,0,0,4)]");
DocNum++ ;
dPlot_Command(DocNum,"[FileSaveAs(1,\"ex01.grf\")]");
dPlot_Command(0, "[FileClose()]");
dPlot_Command(1, "[Activate(1)]");
dPlot_Command(0, "[FileClose()]");
DocNum = dPlot_Command(0, "[FileNew(3)]");

}

Tom
[/code]

Posted: Mon Sep 19, 2005 9:27 am
by DPlotAdmin
At first glance there appears to be a bug with DPlot_AddData. I'll fix this as soon as possible. In the meantime, the following worked for me (using DPlot_Plot rather than DPlot_AddData):

Code: Select all

int		plot;
int		Nz;
XYZ		*Node;
char	cmd[512];

for(plot=0; plot<3; plot++)
{
	Nz = 200*(plot+1);
	Node = (XYZ *)calloc( Nz, sizeof(XYZ));
	for( i=0; i < Nz; i++ ) {
		Node[i].x = -PI + 2*PI * (float)rand()/(float)RAND_MAX;
		Node[i].y = -PI + 2*PI * (float)rand()/(float)RAND_MAX;
		Node[i].z = (float)(sin(Node[i].x) * cos(Node[i].y));
	}
	memset(&DPlot,0,sizeof(DPlot));
	DPlot.Version = DPLOT_DDE_VERSION;
	DPlot.DataFormat = DATA_3DR;
	DPlot.MaxCurves = 1;
	DPlot.MaxPoints = Nz;
	DPlot.NumCurves = 1;
	DPlot.Scale = SCALE_LINEARX_LINEARY;
	strcpy(DPlot.Title[0],"Data sent to DPlot via DPLOTLIB.DLL");
	strcpy(DPlot.Title[1],"z = sin(x)*cos(y)");
	strcpy(DPlot.XAxis,"x");
	strcpy(DPlot.YAxis,"y");
	DocNum = DPlot_Plot8(&DPlot,NULL,(REAL *)Node,"[Caption(\"DPLOTLIB Contour Test\")]"
		"[Contour3D(0)][ContourGrid(0)][ContourMethod(1)][ContourLevels(21,-1,1)]"
		"[FontPoints(1,10)][FontPoints(6,10)][DocMaximize()]");
	DPlot_Command(DocNum,"[GenerateMesh(60,60,-3,-3,3,3,0,0,4)]");
	DocNum++;
	sprintf(cmd,"[FileSaveAs(1,\"c:\\dahs\\dplotw\\test%d.grf\")]",plot+1);
	DPlot_Command(DocNum,cmd); 
	DPlot_Command(0, "[FileClose()]");
	DPlot_Command(1, "[Activate(1)]");
	DPlot_Command(0, "[FileClose()]");
	free(Node);
}

Posted: Tue Sep 20, 2005 5:54 pm
by DPlotAdmin
Tom,
Sorry for the difficulty. Version 2.0.1.1 should work with your original code using DPlot_AddData. You can get it by selecting Help>Check for Updates. Trial version users can get the update from http://www.dplot.com/dplotsetup.exe.

dplot dde repeatedly use

Posted: Tue Sep 20, 2005 11:25 pm
by Tom Chien
David,
Thanks, I am working fine at dplot_Dplot.
By the way, which one is faster, dplot_dplot or dplot_AddData?

Tom

Posted: Tue Sep 20, 2005 11:29 pm
by DPlotAdmin
DPlot_AddData should be faster, since all you're passing is the data values and defaults will be used for other settings. But of course if you're going to be doing things like setting the scale to something other than linear-linear, setting the titles or axis labels, etc., then you're better off using DPlot_Plot.