Cstrike
2010-08-27 22:25:15
In scar we have:
Is there an equivalent of this in Simba? I tried looking for it through the WizzyPlugin and the math functions, but no success.
I created a function for it:
But as you can see, if there is a built in Simba function that would save on the code above :)
Is there a function that I'm missing in Simba? I tried using AMin but it doesn't work as expected [or am I expecting wrong? or did I screw up?] If it doesn't exist, I assume I shall have to use the code I made above?
Thanks
EDIT: for those you who want to see if the scar script won't work can test it with this:
// SCAR
program MyScript;
{
function AMin(Data: TIntegerArray): Integer;
Returns the smallest integer value of all values in Data.
}
var arr : TIntegerArray;
i : Integer;
begin
arr := [1, 5, 8, 123, 58];
i := AMin (arr);
writeln (inttostr(i));
end.
Is there an equivalent of this in Simba? I tried looking for it through the WizzyPlugin and the math functions, but no success.
I created a function for it:
// SIMBA
program MyScript;
{$i SRL/SRL.scar}
function FindMin (TIntArray : TIntegerArray) : Integer;
var i, j : Integer;
minFound : Boolean;
begin
minFound := false;
for i:=0 to high(TIntArray)do // This finds the mode and returns it's value
begin
//writeln ('ATTEMPTING i = '+inttostr(i));
for j:=0 to high(TIntArray) do
begin
//writeln ('j = '+inttostr(j));
if TIntArray[j] < TIntArray[i] then
begin
//writeln ('Found smaller number, '+inttostr(TIntArray[j])+' < '+ inttostr(TIntArray[i]));
Break;
end;
if (j = high(TIntArray)) and not minFound then
begin
minFound := true;
//writeln ('Minimum: ' + inttostr(TIntArray[i]));
result := TIntArray[i];
end;
end;
if minFound then break;
end;
end;
var arr : TIntegerArray;
k : Integer;
begin
SetupSRL;
cleardebug;
arr := [324, 34994, 3933, 134, 5030304, 3949, 9994, 5934, 111111];
k := FindMin (arr);
writeln (inttostr(k));
end.
But as you can see, if there is a built in Simba function that would save on the code above :)
Is there a function that I'm missing in Simba? I tried using AMin but it doesn't work as expected [or am I expecting wrong? or did I screw up?] If it doesn't exist, I assume I shall have to use the code I made above?
Thanks
EDIT: for those you who want to see if the scar script won't work can test it with this:
program MyScript;
{$i SRL/SRL.scar}
var arr : TIntegerArray;
k : Integer;
begin
arr := [5, 6, 9, 2, 4, 1, 10];
k := AMin (arr);
writeln (inttostr(k));
end;