Foundry
2013-11-20 22:06:31
program Grapher;
{$i srl-6/srl.simba}
type YEquals = record
TextForm: String;
XModifier: Double;
YModifier: Double;
end;
function solveForX(x: Integer; Equation: YEquals): Double;
begin
result := (x * Equation.XModifier) + Equation.YModifier;
end;
function makeTPA(SolveFor: YEquals; XRange, YRange: TIntegerArray): TPointArray;
var
x, y, i: Integer;
tpa: TPointArray;
begin
i := 0;
x := XRange[0];
for x to XRange[1] do
begin
tpa[i] := point(x, round(solveForX(x, SolveFor)));
i := i + 1;
end;
end;
procedure graph(Points: TPointArray);
var
i = 0;
begin
WriteLn('Graphing.');
for i to high(Points) do
mouse(Points[i], MOUSE_LEFT);
end;
begin
makeTPA(['3x-2', 3, -2], [0, 10], [0, 10]);
end. I just included the latter part because I was in a hurry. I keep getting access violation at line 24 column 22. I have tried almost everything but haven't got it to work. I am trying to create something that draws the equation of a line in paint.
Compiled successfully in 858 ms.
Exception in Script: Runtime error: "Access violation" at line 24, column 22