line.sml

  Download

More scripts: C A D

Syntax Highlighing:

comments, key words, predefined symbols, class members & methods, functions & classes
            
# line.sml
# demonstrate creating and reading a line CAD element
# draws an amplitude modulated sine wave
cad C;
array numeric xPoints[1000];
array numeric yPoints[1000];
GetOutputCAD(C);
numeric numberPoints = 250, inc = .025;
numeric i, x;
for i = 1 to numberPoints {
	x = i * inc;
	xPoints[i] = x;
	yPoints[i] = sin(x) * cos(10 * x);
	}
CADWriteLine(C, 1, numberPoints, xPoints, yPoints);
# now read and print out the points
numberPoints = CADReadLine(C, 1, 1, xPoints, yPoints);
print("line point list:\n");
numeric elem;
for elem = 1 to numberPoints {
	printf("%4d %6.2 %6.2f\n", elem, xPoints[elem], yPoints[elem]);
	}
	
CloseCAD(C);