7 # define EXIT_SUCCESS 0
11 # define EXIT_FAILURE -1
14 void my_error_function(const char *msg
)
16 fprintf(stderr
, "library message : \"%s\"\n", msg
);
20 main (int argc
, char* argv
[])
24 GraceRegisterErrorFunction (my_error_function
);
26 /* Start Grace with a buffer size of 2048 and open the pipe */
27 if (GraceOpen(2048) == -1) {
28 fprintf (stderr
, "Can't run Grace. \n");
32 /* Send some initialization commands to Grace */
33 GracePrintf ("world xmax 100");
34 GracePrintf ("world ymax 10000");
35 GracePrintf ("xaxis tick major 20");
36 GracePrintf ("xaxis tick minor 10");
37 GracePrintf ("yaxis tick major 2000");
38 GracePrintf ("yaxis tick minor 1000");
39 GracePrintf ("s0 on");
40 GracePrintf ("s0 symbol 1");
41 GracePrintf ("s0 symbol size 0.3");
42 GracePrintf ("s0 symbol fill pattern 1");
43 GracePrintf ("s1 on");
44 GracePrintf ("s1 symbol 1");
45 GracePrintf ("s1 symbol size 0.3");
46 GracePrintf ("s1 symbol fill pattern 1");
48 /* Display sample data */
49 for (i
= 1; i
<= 100 && GraceIsOpen(); i
++) {
50 GracePrintf ("g0.s0 point %d, %d", i
, i
);
51 GracePrintf ("g0.s1 point %d, %d", i
, i
* i
);
52 /* Update the Grace display after every ten steps */
54 GracePrintf ("redraw");
55 /* Wait a second, just to simulate some time needed for
56 calculations. Your real application shouldn't wait. */
62 /* Tell Grace to save the data */
63 GracePrintf ("saveall \"sample.agr\"");
65 /* Flush the output buffer and close Grace */