Results 1 to 4 of 4

Thread: If - Then - Else

  1. #1
    Join Date
    Jan 2009
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default If - Then - Else

    Hey,

    I need to know Why I always get the same error when using else in my script......

    Line 24: [Error] (24:1): Identifier expected in script

    Heres the script:
    SCAR Code:
    Program ColorClicker;

    { --------------- }
    Var
     x, y : integer;
    { --------------- }

    { ------------------- }
    Const
     TheColor = 8425966;
      BeginingX = 232;
       BeginingY = 38;
        EndingX = 355;
         EndingY = 90;
    { ------------------- }

    { ---------------------------------------------------------------------------- }
    Procedure First; { Finds the Color }
     begin
      if FindColor ( x, y, TheColor, BeginingX, BeginingY, EndingX, EndingY ) then
       MoveMouseSmooth ( x, y );
        Wait ( 100 + random ( 100 ) );
         ClickMouse ( x, y, true )
      else
       Wait ( 500 )
        Writeln ( 'Color Missing !' );
     end;
    { ---------------------------------------------------------------------------- }

    { -------------------------------- }
    Begin
     First;
      Wait ( 1000 + random ( 500 ) );
    End.
    { -------------------------------- }

    Help would be appreciated.

    Thanks,

    Fort Ash

  2. #2
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    An End Else statment must be used if your calling more than 1 line after an if statement.

    Fix :

    SCAR Code:
    Procedure First; { Finds the Color }
    begin
      if FindColor ( x, y, TheColor, BeginingX, BeginingY, EndingX, EndingY ) then
       Begin
         MoveMouseSmooth ( x, y );
         Wait ( 100 + random ( 100 ) );
         ClickMouse ( x, y, true )
      End Else
      Begin  
        Wait ( 500 )
        Writeln ( 'Color Missing !' );
      end;
    end;

  3. #3
    Join Date
    Jan 2009
    Posts
    53
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hey,

    Thank You !

    Fort Ash

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

    Default

    SCAR Code:
    if FindColor ( x, y, TheColor, BeginingX, BeginingY, EndingX, EndingY ) then
       Begin

    Good job teaching bad standards right from the beginning, there is no indent between if and begin.

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
  •