Results 1 to 5 of 5

Thread: if, then, else syntax error?

  1. #1
    Join Date
    Jun 2007
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default if, then, else syntax error?

    I can't seem to write an else statement and have it work right. Can someone take a look at this and tell me where I went wrong? The error is:

    Line 191: [Error] (12422:1): Identifier expected in script C:\Documents and Settings\...\My SRL Fletcher1.scar
    Line 191 is the line with only the word else. Here is the part of my script where I get the error. Tell me if you need the full procedure and I'll edit this but the next part of the procedure is the same just for a different item.

    SCAR Code:
    Procedure FletchUnStrung;
    var
      c: integer;
    begin
      if(not(LoggedIn))then exit;
      if(Players[CurrentPlayer].Booleans[0] = False) then
      begin
        repeat
          if(FindDTM(Knife, x, y, MIX1, MIY1, MIX2, MIY2))then
            Mouse(x ,y, 2, 3, True);
            Wait(200 + Random(700));
          else
            Wait(500 + Random(1000));
            ChkInv;
            c := c + 1;
        until c > 3;

    Also if you know of a good tut for "if, then, else" statements please let me know. This is the second one I've had a problem with, the last one I just had an extra set of () around a word but still it stinks to always run into problems with the same type of statement.

  2. #2
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    pm me or msn give us the whole script
    ~Hermen

  3. #3
    Join Date
    Aug 2007
    Posts
    429
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Well since you are doing more than one thing after the 'if' you must use a 'begin'..

    SO:
    SCAR Code:
    Procedure FletchUnStrung;
    var
      c: integer;
    begin
      if(not(LoggedIn))then exit;
      if(Players[CurrentPlayer].Booleans[0] = False) then
      begin
        repeat
          if(FindDTM(Knife, x, y, MIX1, MIY1, MIX2, MIY2))then
          begin //use a begin here
            Mouse(x ,y, 2, 3, True);
            Wait(200 + Random(700));
          end else //then make this 'end else'
          begin //add a begin here
            Wait(500 + Random(1000));
            ChkInv;
            c := c + 1;
          end; //and an end where ever you want it to end the 'else' statement
        until c > 3;

    If you were only doing ONE thing with the if statement then you could do it like that

    SCAR Code:
    begin
     if (This) then DOThis
     else (DoOther)
    end.

    But when doing more than one you must add a begin and an 'end else'

    SCAR Code:
    begin
     if (This) then
     begin
       DOThis;
       AndThis;
     end else (DoOther)
    end.

    Hope that helps =]

  4. #4
    Join Date
    Jun 2007
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks Derek for the help. I knew that I guess with me being new to this though I just can't remember it all. As you can see since Hermpie posted my whole script, which I've asked to have removed, I did that in other parts but forgot it in this part.

    Not really feeling much like scripting right noe maybe I'll see if I can get it all to work tomorrow.

  5. #5
    Join Date
    Jun 2007
    Posts
    88
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Edit: Irrelevant now.

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. Syntax error(need help.)
    By weequ in forum OSR Help
    Replies: 9
    Last Post: 04-04-2008, 04:54 AM
  3. Replies: 5
    Last Post: 02-26-2008, 04:14 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
  •