Log in

View Full Version : functions returning a array?



lardmaster
09-14-2006, 02:04 AM
can they do it? if so, how? plz help, i am working on a script that could be the only autodropping script you'll ever need (hopefully included with SRL)

Yakman
09-14-2006, 06:27 AM
yes it can, heres an example,



function makelinear(gradiant:extended;length,constant:integ er):tpointarray;
var f:integer;
begin
for f:=0 to length do
begin
setarraylength(result,f+1
result[f].x:=f
result[f].y:=round(f*gradiant)+constant
end
end


there, that returns a tpointarray thats in a stright line with the parimeters u specify
you use it like this


var line:tpointarray;d:integer;
begin
line:=makelinear(1,50,0)
for d:=0 to getarraylength(line)-1 do
begin
movemouse(line[d].x,line[d].y)
wait(10)
end
end

WhiteShadow
09-14-2006, 06:42 AM
//Result.
function lardmaster : array of Integer;
begin
SetArrayLength(Result, 3);
Result[0]:= 0;
Result[1]:= 1;
Result[2]:= 2;
end;
//Save in variable.
var
Wh : array[0..5] Of String;

function x90x(xOp : array of Integer) : Boolean;
begin
Wh[0]:= 0;
Wh[1]:= 1;
Wh[2]:= 2;
Result:= True;
end;

lardmaster
09-15-2006, 01:14 AM
thnx u guys, i figured it out on my own, it was for a 2d array, and what i really needed help with was copying, but i got it all now, and its nice to know that SRL is a helpfull community.