
Originally Posted by
Crit Boy
Yay I finally understand it!! Just one more question.
If we had this:
Simba Code:
program New;
* Function GetNumbers(var number: integer): String;
* begin
* * Number := 15
* * result := 'String result';
* end;
* Procedure WriteOurValues;
* var
* * Number, total: Integer;
* begin
* * Total := GetNumbers(Number);
* * Writeln('Our total is '+IntToStr(Total));
* end;
begin
* WriteOurValues;
end.
Would It use number as a result or am I dumb...? I know th coding might be a bit wrong but are basics right?
-Crit
Ps: don't know why there is asterisks in SIMBA code. iPod is retarded..
Nope. When u call a function by its function name (with its respective parameters/parameter-results), it will only return the result type of the function:
function FunctionName(parameters: integer):String;
So when u call this function, it will always return the result type that comes after ":", which is a string. To make use of the results u stored in the parameter, u will just use the declared variable.
Simba Code:
program New;
Function GetNumbers(var number: integer): String;
begin
Number := 15;
result := 'String result';
end;
Procedure WriteOurValues;
var
Number : Integer;
StringStorer: String;
begin
StringStorer:=GetNumbers(Number); //when u call this function, it will always return the string since that is its output
writeln(StringStorer); //this will hence returns 'String result', which is what u defined as the output result of the function
//If u want to make use of the results in the parameter, just name it:
Writeln('Our number is '+IntToStr(Number));
//note that u'll have to call the function first before u can use its parameter-result.
end;
begin
WriteOurValues;
end.
A simpler example would be FindColor(x,y,12345,1,1,1,1):boolean;
So u would usually use the function by:
Simba Code:
procedure abc;
var
x,y: integer; //declare the parameter-result
begin
if FindColor(x,y,12345,1,1,1,1) then //its making use of its output result (the boolean) for the conditional statement
Mouse(x,y,5,5,true); //So after u called the function, u can just use the parameter result (x,y) in another function as long as its called within the same procedure as u called FindColor (unless u declare x,y globally which is not recommended)
writeln(toStr(x)+','+toStr(y)); //see how i can just freely use the parameter result anytime (within the same procedure) again?
end;
Just an example though, u shd always use tolerance in ur rs scripts.