Results 1 to 8 of 8

Thread: String contains?

  1. #1
    Join Date
    Jun 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default String contains?

    Is there a string contains function for scar? Thanks in advance

  2. #2
    Join Date
    Feb 2007
    Location
    USA
    Posts
    667
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Sorry, what? Do you mean like something to check to see if a string contains a certain substring?

  3. #3
    Join Date
    Jun 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    like stringcontains(stringtolookin:string, stringtosearchfor:string):boolean alough that isn't a real function (i don't think at least)

  4. #4
    Join Date
    Mar 2007
    Location
    Under a rock
    Posts
    813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You mean stuff like this?:

    boolean = true/false
    integer = whole numbers
    extended = decimals
    string = letters

    or what?

  5. #5
    Join Date
    Feb 2007
    Location
    USA
    Posts
    667
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    function pos(substr, s: string): Longint

    This looks for the substring inside string 's'. If it is found it will tell you at what position in the string the substring starts at. If it is not found, it returns 0.

    So to check if the substring was in it, you could do

    SCAR Code:
    if (pos('str', 'string') != 0) then
       writeln('Found substring!');

  6. #6
    ronny.m.p Guest

    Default

    Lol omghax0rz do you read the srl and scar manuals for fun?

  7. #7
    Join Date
    Feb 2007
    Location
    USA
    Posts
    667
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yup
    jk

  8. #8
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    That's not in the SRL manual ... but I read it for fun.

    SCAR Code:
    function StrContains(Str, Substr: String): Boolean;
    begin
      Result:= (Pos(Substr, Str) <> 0);
    end;

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 03-30-2008, 01: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
  •