|
|
ACON
Home/Topics |
Commands |
More Examples

/* User-defined Functions Example */
/* Using the Script Keywords built into ACON */
/* it is possible to define new functions which automate tasks.
*/
/* Here is the script of a function to plot the sin of x, */
/* as x varies from 0 to "max_radians" radians. */
/* The function has 1 parameter, the "max_radians" value.
*/
/* */
Function Sin_Curve(max_radians)
{
Data_Window(0,max_radians,-1.1,1.1); /* set the x,y axis limits*/
Data_Viewport(mm(30),mm(110),mm(200),mm(270));
Data_Projection("NIL"); /* turn off any projection */
Line_Type(0); /* use a solid line */
Axis(1,1,0,0,1,0,1,0,0); /* draw the axis around the plot */
objstart("line"); /* the sin curve is a continuous line object */
Line_Type(1); /* use a dashed line for the curve */
x = 0; /* x will vary from 0...15. */
Draw(xuser(x),yuser(sin(x)),0); /* move to the 1st x,y point */
while (x < max_radians) do /* major loop to draw each segment*/
{
Draw(xuser(x),yuser(sin(x)),1); /* draw to the next x,y pt */
x = x + 0.1;
};
Draw(xuser(x),yuser(sin(x)),999); /* draw the last pt */
Line_Type(0); /* reset to solid line to be safe */
objend("line");
};
Next_Page();
/* Execute our new function using a value of 15 for max_radians*/
Sin_Curve(15);
ACON
Home/Topics |
Commands |
More Examples
|
Last Modified : 2003-11-19
|
|