Re: Wrapping a C library.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Greg,

I'm getting a type check error when I use the gnuplot_plot_xy() function.

Looking at the include file, I see that the parameters x and y are atoms, however, writing the euphoria equivalent of the example given in the documentation:

 gnuplot_ctrl    *h ; 
    double          x[50] ; 
    double          y[50] ; 
    int             i ; 
 
    h = gnuplot_init() ; 
    for (i=0 ; i<50 ; i++) { 
        x[i] = (double)(i)/10.0 ; 
        y[i] = x[i] * x[i] ; 
    } 
    gnuplot_plot_xy(h, x, y, 50, "parabola") ; 
    sleep(2) ; 
    gnuplot_close(h) ; 

was when I got the error.

I took it that x and y being arrays here, then in the corresponding Eu code x and y would be sequences.

I think this is something to do with the fact that x and y are not actually arrays, but pointers to arrays. Unfortunately my knowledge of C is nil so I'm just confused...

Here is the code generating the error -

include "gnuplot_i.e" 
include std/console.e 
sequence x, y  
 
x = {} 
y = {} 
gnuplot_ctrl g = gnuplot_init() 
 
for i = 0.1 to 5 by 0.1 do 
    x &= i 
    y &= i*i 
end for 
 
gnuplot_plot_xy(g, x, y, 50, "parabola") 
 
any_key() 
gnuplot_close( g ) 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu