DPLOT_AddData

Have a suggestion for improving DPlot or a question about existing features? Let us know

Moderator: DPlotAdmin

Post Reply
cmmenez
Posts: 3
Joined: Fri Jul 23, 2004 7:17 am

DPLOT_AddData

Post by cmmenez »

Hi,

I'm new to this program, so may be this question has a simple answer.
I´m trying to create a new XY plot on an existing XY plot
(generated using the DPLOT_PLOT subroutine)
For that I'm using the DPLOT_AddData subroutine in Fortran and the DATA_XYXY data type as input parameter. and "0" as the CURVE parameter.
Strangely the DPLOT_AddData subroutine returns the "-3" result which means "Unsupported Data type".

Can anyone help me on this?

Carlos
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Sorry for the delayed reply... it's been a long day on the road.

The error return code is bogus and I'll be certain to fix that in the next release.

Curve indices in DPlot functions are 1-based rather than 0-based (there is no curve 0, in other words). If you already have N curves in the plot and want to create a new curve, use N+1 for the Curve parameter. If you just want to add data to an existing curve, use that curve's 1-based index.

If I haven't answered your question please let me know.
Visualize Your Data
support@dplot.com
cmmenez
Posts: 3
Joined: Fri Jul 23, 2004 7:17 am

DPLOT_AddData

Post by cmmenez »

Dear David,

Probably the sequence of commands help to explain my doubts:

this will plot a x,y plot,
ret = DPlot_Plot( DPVersion, x, y, cString )
I have almost copied the instructions you have written for the first
example in the ftest.program,

Now some stuff to generate the x1,y1 curve
Finally I want to add the plot of this new curve to the previous one
and I used the following instruction:
ret1 = DPlot_AddData( ret, DATA_XYXY, NPOINTS1, 0,x1, y1)
The "0" is because in the "README.pdf" manual it says that for a new curve one must use CURVE=0. Anyway I have tried other curve indexes
(2, 3) within the range from 1 to the maximum number of curves, and the answer was always "-3", meaning "Invalid data type".



Thank you for your attention.
Carlos
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Carlos,
Sorry, I should have paid more attention to this the first time. There's no way I can see to get that error code from DPLOTLIB unless the data type really is a bad value. So that means either

1) DATA_XYXY is defined wrong. This is unlikely or you would have had problems with other functions, but just in case... it should be = 0.

2) The interface for DPlot_AddData is incorrect. I'd guess this is the problem since none of the Fortran examples use DPlot_AddData. What compiler do you use?

With WATCOM Fortran you should have:

Code: Select all

c$pragma aux (__stdcall) DPlot_AddData "DPlot_AddData" parm (value,value,value,value,reference,reference)
With Compaq Visual Fortran you should have something like:

Code: Select all

      INTERFACE
         INTEGER FUNCTION DPlot_AddData(DocNum, DataType, NumPts, Curve, array1, array2)
           !DEC$ ATTRIBUTES STDCALL :: DPlot_AddData
           !DEC$ ATTRIBUTES ALIAS:'_DPlot_AddData@24' :: DPlot_AddData
            INTEGER*4     DocNum
            INTEGER*4     DataType
            INTEGER*4     NumPts
            INTEGER*4     Curve
            REAL*4        array1
            REAL*4        array2
           !DEC$ ATTRIBUTES VALUE :: DocNum
           !DEC$ ATTRIBUTES VALUE :: DataType
           !DEC$ ATTRIBUTES VALUE :: NumPts
           !DEC$ ATTRIBUTES VALUE :: Curve
           !DEC$ ATTRIBUTES REFERENCE :: array1
           !DEC$ ATTRIBUTES REFERENCE :: array2
         END FUNCTION
      END INTERFACE
The important issue is that those first 4 parameters are passed by value rather than by reference, which is counter to the Fortran default.
Visualize Your Data
support@dplot.com
cmmenez
Posts: 3
Joined: Fri Jul 23, 2004 7:17 am

Post by cmmenez »

Dear David,

I'm using the g77 compiler under the Force IDE.
The DATA_XYXY is set to 0 as you mentioned. So it is correctly specified.
Therefore it remains your second hypothesis: the interface for DPlot_AddData is incorrect.
I think I should know I must pass by value those four parameters. Or can't I with the g77 compiler? I will try the non standard %VAL() command (if it is implemented).
Sorry for the trouble.

Carlos
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Carlos,
I don't have that compiler handy at the moment but I'm sure you can pass parameters by value. If you don't figure it out soon don't despair; I'll post the answer here but it will be later this weekend.
Visualize Your Data
support@dplot.com
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Carlos,
%VAL() will do the trick, but there's still a problem that I haven't figured out but perhaps you already have: the example I built runs fine once, twice, maybe 3 or 4 times if I'm lucky. But eventually it will crash after repeating the same operation (creating a new plot) several times. I'm reasonably sure this is because all of the DPLOTLIB.DLL functions are stdcall (same calling convention used by Windows API), and I'm unable to figure out yet how to tell g77 that. This ends up causing a stack problem eventually so that the program crashes. If you know the answer, please clue me in. Otherwise I'll keep looking.
Visualize Your Data
support@dplot.com
Post Reply