DPlot Forum Index DPlot
http://www.dplot.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

DPLOT_AddData

 
Post new topic   Reply to topic    DPlot Forum Index -> Suggestions/Questions
View previous topic :: View next topic  
Author Message
cmmenez



Joined: 23 Jul 2004
Posts: 3

PostPosted: Fri Jul 23, 2004 7:29 am    Post subject: DPLOT_AddData Reply with quote

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
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Fri Jul 23, 2004 7:17 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cmmenez



Joined: 23 Jul 2004
Posts: 3

PostPosted: Sat Jul 24, 2004 5:08 am    Post subject: DPLOT_AddData Reply with quote

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
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Sat Jul 24, 2004 6:16 am    Post subject: Reply with quote

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:
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:
      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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
cmmenez



Joined: 23 Jul 2004
Posts: 3

PostPosted: Sat Jul 24, 2004 6:41 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Sat Jul 24, 2004 8:35 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
DPlotAdmin
Site Admin


Joined: 24 Jun 2003
Posts: 2310
Location: Vicksburg, Mississippi

PostPosted: Sat Jul 24, 2004 4:48 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DPlot Forum Index -> Suggestions/Questions All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group