Results 1 to 5 of 5

Thread: need help with my function

  1. #1
    Join Date
    Jan 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default need help with my function

    I made function that returns true if it finds two same numbers out of nine.

    SCAR Code:
    function samenumbers(k1,k2,k3,k4,k5,k6,k7,k8,k9: integer): boolean;
    begin
    if
    k1=k2 or k1=k3 or k1=k4 or k1=k5 or k1=k6 or k1=k7 or k1=k8 or k1=k9 or
    k2=k3 or k2=k4 or k2=k5 or k2=k6 or k2=k7 or k2=k8 or k2=k9 or
    k3=k4 or k3=k5 or k3=k6 or k3=k7 or k3=k8 or k3=k9 or
    k4=k5 or k4=k6 or k4=k7 or k4=k8 or k4=k9 or k5=k6 or k5=k7 or k5=k8 or
    k5=k9 or k6=k7 or k6=k8 or k6=k9 or k7=k8 or k7=k9 or k8=k9
    then
    result:=true
    else
    result:=false
    end;

    begin
    end.


    but somehow it doesnt work... i dont know why
    end.

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

    Default

    you need to call the function in your main loop between your last begin/end.

  3. #3
    Join Date
    Jan 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i know, but it still doesnt work
    it sayes:
    Failed when compiling
    Line 4: [Error] (4:21): Type mismatch in script
    end.

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

    Default

    SCAR Code:
    function samenumbers(k1,k2,k3,k4,k5,k6,k7,k8,k9: integer): boolean;
    begin
      if((k1=k2) or (k1=k3) or (k1=k4) or (k1=k5) or (k1=k6) or (k1=k7) or (k1=k8) or (k1=k9) or
      (k2=k3) or (k2=k4) or (k2=k5) or (k2=k6) or (k2=k7) or (k2=k8) or (k2=k9) or
      (k3=k4) or (k3=k5) or (k3=k6) or (k3=k7) or (k3=k8) or (k3=k9) or
      (k4=k5) or (k4=k6) or (k4=k7) or (k4=k8) or (k4=k9) or (k5=k6) or (k5=k7) or (k5=k8) or
      (k5=k9) or (k6=k7) or (k6=k8) or (k6=k9) or (k7=k8) or (k7=k9) or (k8=k9))then
        result:=true
      else
        result:=false;
    end;
    You just needed parentheses

  5. #5
    Join Date
    Jan 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thx it works now
    end.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2008, 05:20 PM
  2. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  3. Any function that does this?
    By shadowpwner in forum OSR Help
    Replies: 2
    Last Post: 08-14-2007, 03:15 AM
  4. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 AM

Posting Permissions

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