Results 1 to 9 of 9

Thread: My own error

  1. #1
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default My own error

    SCAR Code:
    procedure Checks3;
      begin
        if (Colour = '')        or
           (Colour = 'Cyan:')   or
           (Colour = 'Red:')    or
           (Colour = 'Purple:') or
           (Colour = 'White:')  or
           (Colour = 'Green:')  or
           (Colour = 'Glow1:')  or
           (Colour = 'Glow2:')  or
           (Colour = 'Glow3:')  or
           (Colour = 'Flash1:') or
           (Colour = 'Flash2:') or
           (Colour = 'Flash3:') then
        begin
          WriteLn('You have correctly entered a colour.');
          Wait(2000);
          WriteLn('Now to check whether you'#39've done the same an effect!');
          Wait(3500);
          ClearDebug;
        end;
       
      begin
        if not (Colour = '')        or
               (Colour = 'Cyan:')   or
               (Colour = 'Red:')    or
               (Colour = 'Purple:') or
               (Colour = 'White:')  or
               (Colour = 'Green:')  or
               (Colour = 'Glow1:')  or
               (Colour = 'Glow2:')  or
               (Colour = 'Glow3:')  or
               (Colour = 'Flash1:') or
               (Colour = 'Flash2:') or
               (Colour = 'Flash3:') then
            begin
              WriteLn('There is an error with the colour you have entered. Please read');
              WriteLn('lines 32 - 43 of the script.');
              Wait(4000);
              WriteLn('Stopping Script');
              TerminateScript;
            end;
      end;

    This is part of my script that I am currently working on. When I run it, it gets to this part, and it says
    Code:
     You have correctly entered a colour.
    Now to check whether you've done the same an effect!
    Fair enough, because I have correctly entered a colour. But after that, it comes up
    Code:
    There is an error with the colour you have entered. Please read
    lines 32 - 43 of the script.
    Stopping Script
    in the debug box.

    Can anyone tell me why even though I have correctly entered a colour, the script thinks I have not? Also, if possible, could you show me what it should be like so that if the colour is correct, the script detects it as correct, and if wrong, detects it as wrong?

    Thanks in advance,
    R1ch4
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  2. #2
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    SCAR is picky with parentheses, like it should be (but that's what is also causing your error). Your code there says: "If the colour is NOT '' or the color IS the rest of the ones listed, display this message." Replace that with this:

    SCAR Code:
    if not ((Colour = '')        or
               (Colour = 'Cyan:')   or
               (Colour = 'Red:')    or
               (Colour = 'Purple:') or
               (Colour = 'White:')  or
               (Colour = 'Green:')  or
               (Colour = 'Glow1:')  or
               (Colour = 'Glow2:')  or
               (Colour = 'Glow3:')  or
               (Colour = 'Flash1:') or
               (Colour = 'Flash2:') or
               (Colour = 'Flash3:')) then
    It should work after that.
    :-)

  3. #3
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    EDIT: Sorry, it still doesn't work.

    Even though I have set Colour as Cyan:, it is still detecting it as an invalid colour.

    SCAR Code:
    if not (Colour = '')        or
               (Colour = 'Cyan:')   or
               (Colour = 'Red:')    or
               (Colour = 'Purple:') or
               (Colour = 'White:')  or
               (Colour = 'Green:')  or
               (Colour = 'Glow1:')  or
               (Colour = 'Glow2:')  or
               (Colour = 'Glow3:')  or
               (Colour = 'Flash1:') or
               (Colour = 'Flash2:') or
               (Colour = 'Flash3:') then
            begin
              WriteLn('There is an error with the colour you have entered. Please read');
              WriteLn('lines 32 - 43 of the script.');
              Wait(4000);
              WriteLn('Stopping Script');
              TerminateScript;
            end;

      begin
        WriteLn('You have correctly entered a colour.');
        Wait(2000);
        WriteLn('Now to check whether you'#39've done the same an effect!');
        Wait(3500);
        ClearDebug;
      end;

    The part where you set up Colour:

    SCAR Code:
    const
        Colour = 'Cyan:'; //Choose from: Cyan, Red, Purple, White, Green,
                             //Glow1, Glow2, Glow3, Flash1, Flash2, Flash3. Leave
                             //the colon (:) in at the end.

    Anyone got any advice so that it doesn't detect Cyan: as an incorrect colour?

    Thanks,
    R1ch4
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  4. #4
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Also to save space, you can use "else" instead of rewriting the entire if-then statement.

    SCAR Code:
    procedure Checks3;
      begin
        if ((Colour = '')        or
           (Colour = 'Cyan:')   or
           (Colour = 'Red:')    or
           (Colour = 'Purple:') or
           (Colour = 'White:')  or
           (Colour = 'Green:')  or
           (Colour = 'Glow1:')  or
           (Colour = 'Glow2:')  or
           (Colour = 'Glow3:')  or
           (Colour = 'Flash1:') or
           (Colour = 'Flash2:') or
           (Colour = 'Flash3:')) then
        begin
          WriteLn('You have correctly entered a colour.');
          Wait(2000);
          WriteLn('Now to check whether you'#39've done the same an effect!');
          Wait(3500);
          ClearDebug;
        end
          else begin
            WriteLn('There is an error with the colour you have entered. Please read');
              WriteLn('lines 32 - 43 of the script.');
              Wait(4000);
              WriteLn('Stopping Script');
              TerminateScript;
          end;
    Unfortunately, no active scripts atm.

  5. #5
    Join Date
    Mar 2007
    Posts
    3,042
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    It's the same thing as before, basically. The snippet you posted two posts above this one doesn't have the parentheses that I added. doom0791's code should work correctly.
    :-)

  6. #6
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Oh sorry, I didn't see the added brackets.

    I'll just test it like that.

    EDIT: Thanks, that got it working. Do you like the sound of some rep? Now I just have an error with the AntiRandoms script in my SRL folder:

    Code:
    [Runtime Error] : Out Of Range in line 1103 in script D:\Program Files\SCAR 3.15\includes\SRL/SRL/Core/AntiRandoms/AntiRandoms.scar
    from

    SCAR Code:
    begin;
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(1);
      FindColorsTolerance(TPA, 65535, 3, 3, 515, 336, 0);
      if FindTPAinTPA(Players[CurrentPlayer].NickTPA,TPA,Matches) then THIS LINE //Length check inside the function ;)
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  7. #7
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Posts
    930
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ahh my friend. you have to put a not in front of every condition
    ~ Metagen

  8. #8
    Join Date
    May 2007
    Location
    England
    Posts
    4,140
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by doom0791 View Post
    Also to save space, you can use "else" instead of rewriting the entire if-then statement.
    Sorry, I didn't see your post. Thanks for the reply anyway. Anyway, because at the end of the part where it checks whether the colour isn't a valid one, I have
    Code:
    TerminateScript;
    So if it was an invalid colour the script would stop. If it wasn't an invalid colour, it would just skip that part. So now I have:

    SCAR Code:
    if not ((Colour = '')        or
               (Colour = 'Cyan:')   or
               (Colour = 'Red:')    or
               (Colour = 'Purple:') or
               (Colour = 'White:')  or
               (Colour = 'Green:')  or
               (Colour = 'Glow1:')  or
               (Colour = 'Glow2:')  or
               (Colour = 'Glow3:')  or
               (Colour = 'Flash1:') or
               (Colour = 'Flash2:') or
               (Colour = 'Flash3:')) then
            begin
              WriteLn('There is an error with the colour you have entered. Please read');
              WriteLn('lines 32 - 43 of the script.');
              Wait(4000);
              WriteLn('Stopping Script');
              TerminateScript;
            end;

      begin
        WriteLn('You have correctly entered a colour.');
        Wait(2000);
        WriteLn('Now to check whether you'#39've done the same an effect!');
        Wait(3500);
        ClearDebug;
      end;

    So now there is no need for else or if,then.

    @ Metagen - I don't have to put not in front of each Colour. It works perfectly fine as it is. Thank you for your reply though.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  9. #9
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    If you do not use the extra parentheses:

    SCAR Code:
    ///////*
    if not ((Colour = '')        or
               (Colour = 'Cyan:')   or
               (Colour = 'Red:')    or
               (Colour = 'Purple:') or
               (Colour = 'White:')  or
               (Colour = 'Green:')  or
               (Colour = 'Glow1:')  or
               (Colour = 'Glow2:')  or
               (Colour = 'Glow3:')  or
               (Colour = 'Flash1:') or
               (Colour = 'Flash2:') or
               (Colour = 'Flash3:')) then
    ///////////////////////////////*
    Then you will have to put a not infront of each colour. Otherwise its like you're saying:
    if not Colour1 or {YES} Colour2 or {YES} Colour3.... etc.

    With the extra parentheses ur saying:
    if not ({YES} Colour1 or {YES} Colour2... etc.).. Kindof like a distributive property:

    a(b + c) = ab + ac.
    not(colour1 or colour2) = not colour1 or not colour2.

    Hopefully that helps to understand it a little better.
    Unfortunately, no active scripts atm.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Line 135: [Error] (14845:1): Syntax error in script
    By AbsTrACt'^.| in forum OSR Help
    Replies: 16
    Last Post: 05-23-2008, 01:14 PM
  2. Replies: 5
    Last Post: 02-26-2008, 04:14 PM
  3. Smart error and Some kind of Math.scar error
    By FagetHax0r in forum OSR Help
    Replies: 6
    Last Post: 02-24-2008, 10:43 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
  •