Results 1 to 5 of 5

Thread: Two UpText Functions

  1. #1
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Two UpText Functions

    here are two Uptext Functions i made,

    SCAR Code:
    {Returns the uptext that is there out of the "possible" string array in the
    variable Item and returns true/false whether or not one is found}


    Function WhatIsUpText(var Item: String; Possible: TStringArray): Boolean;
    var
      h, highest, l: integer;
      t: String;

    begin
      t := rs_getupText;
      highest := High(Possible);
      for h := 0 to highest do
      begin
        if pos(Possible[h],t) <> 0 then
        begin
          inc(l);
          Item := Possible[h];
        end;
      end;
      if l = 1 then
        Result := True
      else
      begin
        Result := False;
        Item := '';
      end;
    end;


    {Returns whether or not all the strings are found in the Uptext}

    Function AllUpTexts(Texts: TStringArray): Boolean;
    var
      h, i, Many: integer;
      t: String;
    begin
      t := rs_GetUpText;
      h := high(Texts);
      for i := 0 to h do
      begin
        if pos(Texts[h], t) <> 0 then inc(many);
      end;
      if Many = length(Texts) then Result := true;
    end;

    if they don't work for you, tell me.
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  2. #2
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Those had a lot of errors, please test before posting.

    SCAR Code:
    Function WhatIsUpText(var Item: String; Possible: TStringArray): Boolean;
    var
      h, highest, l: integer;
      t: String;

    begin
      t := rs_getupText;
      highest := High(Possible);
      for h := 0 to highest do
        if pos(Possible[h],t) <> 0 then
        begin
          inc(l);
          Item := Possible[h];
        end;
      if l = 1 then
        Result := True
      else
      begin
        Result := False;
        Item := '';
      end;
    end;


    SCAR Code:
    Function AllUpTexts(Texts: TStringArray): Boolean;
    var
      h, i, Many: integer;
      t: String;
    begin
      t := rs_GetUpText;
      h := high(Texts);
      for i := 0 to h do
        if pos(Texts[i], t) > 0 then inc(many);
      if Many = length(Texts) then Result := true;
    end;

  3. #3
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    from what i see you've changed, its not really an error, just took out an unnecessary begin/end; on each.

    and it is the public test corner, so i figured the public could test it.
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

  4. #4
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Haha, you are wrong - try to run your ones.


    a) In both functions you tried to store the uptext to an integer.
    b) In the other you forgot a close round.
    c) You can't have a semicolon after the first statement in an If - Then - Else.
    d)
    SCAR Code:
    var Item: String,
    e)
    SCAR Code:
    if pos(Texts, t) then
    You forgot the comparing
    f)
    SCAR Code:
    pos(Texts, t)
    You tried to find the postion of a TStringArray?


    Have a nice day.

  5. #5
    Join Date
    Sep 2007
    Posts
    415
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow. i can't believe i messed up that much in a simple little function. thank you for pointing those out

    all fixed and tested, work beautifully.
    Quote Originally Posted by That guy that wrote forefeathers
    <munklez>haha im too lazy, girls annoy me
    <munklez> they always wanna like, do stuff
    <munklez> and i just wanna program
    <munklez> and they always take all my money

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. EnterRCAltar uptext
    By Psychor in forum OSR Help
    Replies: 6
    Last Post: 02-04-2008, 08:40 PM

Posting Permissions

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