Results 1 to 13 of 13

Thread: (Another) Quick Question

  1. #1
    Join Date
    Aug 2009
    Posts
    164
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default (Another) Quick Question

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

    Thanks!

  2. #2
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function Whatever(Something: Boolean): Boolean;
    begin
      Result := Something;
    end;

  3. #3
    Join Date
    Aug 2009
    Posts
    164
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Perfect, Thanks

    What goes in something? the boolean variable?
    and result := true or false?

  4. #4
    Join Date
    Sep 2007
    Location
    Pennsylvania
    Posts
    3,396
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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

  5. #5
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    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

  6. #6
    Join Date
    Aug 2009
    Posts
    164
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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:

    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;
    Call to the function: (check is a boolean defined in the procedure containing these lines)

    Code:
         while not(ContinueCheck(check)) do
         begin
              writeln('NPC not found, trying again');
         end;
         writeln('NPC Found!');

  7. #7
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    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 guy keep it up
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  8. #8
    Join Date
    Aug 2009
    Posts
    164
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks, Awkwardsaw! I'm trying to write something decent for my application

  9. #9
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by scuz 10 View Post
    Thanks, Awkwardsaw! I'm trying to write something decent for my application
    what are you making
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  10. #10
    Join Date
    Aug 2009
    Posts
    164
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Awkwardsaw View Post
    what are you making
    tutorial island script...that function keeps returning true when the click here to continue option isn't present...any ideas?

    Edit: Seems to be working for now
    Last edited by scuz 10; 08-25-2009 at 11:53 AM.

  11. #11
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    Quote Originally Posted by scuz 10 View Post
    tutorial island script...that function keeps returning true when the click here to continue option isn't present...any ideas?

    Edit: Seems to be working for now
    a tut runner would be epic for an application man.

    and just fyi, the click to continue function is already in anti- randoms includes

    if you need any help, pm me or add me on messenger
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  12. #12
    Join Date
    May 2008
    Posts
    1,345
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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

  13. #13
    Join Date
    May 2008
    Location
    Oregon, USA
    Posts
    154
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •