Is there a way to make procedures return values? Such as true and false?
Thanks!
Is there a way to make procedures return values? Such as true and false?
Thanks!

SCAR Code:function Whatever(Something: Boolean): Boolean;
begin
Result := Something;
end;
Perfect, Thanks
What goes in something? the boolean variable?
and result := true or false?
result := true;
or
result := false;
You can also make functions return other types as well, just replace boolean in
function Something: boolean;
to another type![]()
and, if you where trying to find an uptext for example, then you can just do
SCAR Code:function wat(uptext: string): boolean;
begin
result:= isuptext(uptext);
end;
because isuptext is a function that returns a boolean, and what ever isuptext returns, the function wat will return
<TViYH> i had a dream about you again awkwardsaw
Malachi 2:3
Ok, I am trying to make a function that will return true or false depending on whether or not the "click here to continue" text was found...please let me know if I am doing this right:
Call to the function: (check is a boolean defined in the procedure containing these lines)Code:function ContinueCheck(CCheck:Boolean):Boolean; begin If FindTextTPA(ClBlue,30,233,449,378,458,'ontinue',NPCChars,Nothing)then begin Result :=True; writeln('"Click here to continue" found!'); end else begin Result:= False; end; end;
Code:while not(ContinueCheck(check)) do begin writeln('NPC not found, trying again'); end; writeln('NPC Found!');
it can be shortened to this:
SCAR Code:function ContinueCheck(CCheck:Boolean):Boolean;
begin
Result :=FindTextTPA(ClBlue,30,233,449,378,458,'ontinue',NPCChars,Nothing);
if result then writeln('"Click here to continue" found!');
end;
because, FindTextTPA returns a boolean, so if it returns true, result = true.
also, you dont need to set a function false, unless youve set it to true
one more thing, CCheck isnt used, incase you didnt know
also, this is a nice job for a new guykeep it up
<TViYH> i had a dream about you again awkwardsaw
Malachi 2:3
Thanks, Awkwardsaw! I'm trying to write something decent for my application![]()
Just as an afterthought, I created this a while ago. Not the best, but it might be helpful:
http://www.villavu.com/forum/showthread.php?t=39389
~Sandstorm
As others have said use functions if you want it to return something... I would reccomend reading guides about this stuff... Other things you can do are specify variables in the calling of the procedure/ Fuction. example:
My Grand exchange price finder...
SCAR Code:function GrabPriceMed(ItemId: String): integer;
var
s : string;
begin
s := getpage(('http://itemdb-rs.runescape.com/Potato/viewitem.ws?obj=') + (ItemId))
s := between('<b>Market price:</b>','</span>',s);
s := getnumbers(s);
Result := strtoint(s);
end;
As you can see when i would call for the function i would provide the id of the item that i would like to find the price of without having to change the procedure around a million times... You might find this very helpfull when trying to make a very clean script.
There are currently 1 users browsing this thread. (0 members and 1 guests)