i know in c++ you have to put "&" before the variable but how do you do it in scar
i know in c++ you have to put "&" before the variable but how do you do it in scar
"your always where you supposed to be"
SCAR Code:Program New;
Var
x, y, x1, y1, x2, y2: Integer;// replace and with ","
// if thats what you mean...
begin
x1 := 0;
y1 := 0;
x2 := 713;
y2 := 515;
If (FindColor(x, y, 0, x1, y1, x2, y2)) then
Writeln('found Color');
end;
SCAR Code:Function(var Return1: Integer; var Return2: String; var Return3: TPoint): Boolean;
This would return an integer, a string, a TPoint and a Boolean. Just put var before what you want to be returned.
thanks alot nielsie
"your always where you supposed to be"



I don't understand your post Neilsie...
You could do something like this, with variants...SCAR Code:function ReturnMultiple: Array of Variant;
begin
Result[0]:= 'hi';
Result[1]:= 5;
Result[2]:= 5.5;
Result[3]:= True;
end;
As long as you manipulate GLOBAL variables in the function, you can use them other places in the script. There may be other better ways to do it, but that's how I do it.
For example:
That uses LOCAL variables (e,f,g), so it doesn't actually change the values returned.Code:Program ReturnTheVars; var a,b,c:integer; procedure ChangeVars(e,f,g:integer); begin e:=e+1; f:=f+10; g:=g+100; end; begin a:=5; b:=5; c:=5; ChangeVars(a,b,c); Writeln(IntToStr(a)+','+IntToStr(b)+','+InttoStr(c)); end.
That ALSO uses local variables. The a, b, and c that are changed are local to that procedure, not the global variable seen elsewhere in the script.Code:Program ReturnTheVars; var a,b,c:integer; procedure ChangeVars(a,b,c:integer); begin a:=a+1; b:=b+10; c:=c+100; end; begin a:=5; b:=5; c:=5; ChangeVars(a,b,c); Writeln(IntToStr(a)+','+IntToStr(b)+','+InttoStr(c)); end.
That one uses the Global variables, so it changes all the values.Code:Program ReturnTheVars; var a,b,c:integer; procedure ChangeVars; begin a:=a+1; b:=b+10; c:=c+100; end; begin a:=5; b:=5; c:=5; ChangeVars; Writeln(IntToStr(a)+','+IntToStr(b)+','+InttoStr(c)); end.
yea but my programming teacher said you should use as little global vars as possible so functions can be used for multiple programs
"your always where you supposed to be"
Yeah, it's bad coding practices, but I'm not that great of coder. Pretty much all self-taught. Anybody that has even had a recent introductory class to pascal would have a leg up on me.
However, I am usually able to get the spaghetti code to function as I want it to.
There are currently 1 users browsing this thread. (0 members and 1 guests)