Results 1 to 7 of 7

Thread: Syntax Error In Script | Highlighting And Statement!

  1. #1
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default Syntax Error In Script | Highlighting And Statement!

    Well, i am trying to make this new function as a test and it is not quite working out. The error is as follows:
    Code:
    Line 3: [Error] (3:15): Syntax error in script 
    Failed when compiling
    And the script is as follows:
    SCAR Code:
    function IsFKeyUp(Num: Byte): Boolean;
    begin
      if(Num=1) and if(KeyUp(112)) then Result:=True;
      if(Num=2) and if(KeyUp(113)) then Result:=True;
      if(Num=3) and if(KeyUp(114)) then Result:=True;
      if(Num=4) and if(KeyUp(115)) then Result:=True;
      if(Num=5) and if(KeyUp(116)) then Result:=True;
      if(Num=6) and if(KeyUp(117)) then Result:=True;
      if(Num=7) and if(KeyUp(118)) then Result:=True;
      if(Num=8) and if(KeyUp(119)) then Result:=True;
      if(Num=9) and if(KeyUp(120)) then Result:=True;
      if(Num=10) and if(KeyUp(121)) then Result:=True;
      if(Num=11) and if(KeyUp(122)) then Result:=True;
      if(Num=12) and if(KeyUp(123)) then Result:=True;
      if(Num=13) and if(KeyUp(124)) then Result:=True;
      if(Num=14) and if(KeyUp(125)) then Result:=True;
      if(Num=15) and if(KeyUp(126)) then Result:=True;
      if(Num=1) and if not (KeyUp(112)) then Result:=False;
      if(Num=2) and if not (KeyUp(113)) then Result:=False;
      if(Num=3) and if not (KeyUp(114)) then Result:=False;
      if(Num=4) and if not (KeyUp(115)) then Result:=False;
      if(Num=5) and if not (KeyUp(116)) then Result:=False;
      if(Num=6) and if not (KeyUp(117)) then Result:=False;
      if(Num=7) and if not (KeyUp(118)) then Result:=False;
      if(Num=8) and if not (KeyUp(119)) then Result:=False;
      if(Num=9) and if not (KeyUp(120)) then Result:=False;
      if(Num=10) and if not (KeyUp(121)) then Result:=False;
      if(Num=11) and if not (KeyUp(122)) then Result:=False;
      if(Num=12) and if not (KeyUp(123)) then Result:=False;
      if(Num=13) and if not (KeyUp(124)) then Result:=False;
      if(Num=14) and if not (KeyUp(125)) then Result:=False;
      if(Num=15) and if not (KeyUp(126)) then Result:=False;
    end;

    Thank-you for reading
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

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

    Default

    You're using if wrong. You either use it like
    SCAR Code:
    if(Num=1)then if(KeyUp(112)) then Result:=True;
    or
    SCAR Code:
    if(Num=1) and (KeyUp(112)) then Result:=True;


  3. #3
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by bullzeye95 View Post
    You're using if wrong. You either use it like
    SCAR Code:
    if(Num=1)then if(KeyUp(112)) then Result:=True;
    or
    SCAR Code:
    if(Num=1) and (KeyUp(112)) then Result:=True;

    Thanks

    I wasn't paying attention to the if, only the and. I guess it is like the or statement too.

    But now i get this error:
    Code:
    Line 3: [Error] (3:28): Type mismatch in script
    and here is the function now:
    SCAR Code:
    function IsFKeyUp(Num: Byte): Boolean;
    begin
      if(Num=1) and (KeyUp(112)) then Result:=True;
      if(Num=2) and (KeyUp(113)) then Result:=True;
      if(Num=3) and (KeyUp(114)) then Result:=True;
      if(Num=4) and (KeyUp(115)) then Result:=True;
      if(Num=5) and (KeyUp(116)) then Result:=True;
      if(Num=6) and (KeyUp(117)) then Result:=True;
      if(Num=7) and (KeyUp(118)) then Result:=True;
      if(Num=8) and (KeyUp(119)) then Result:=True;
      if(Num=9) and (KeyUp(120)) then Result:=True;
      if(Num=10) and (KeyUp(121)) then Result:=True;
      if(Num=11) and (KeyUp(122)) then Result:=True;
      if(Num=12) and (KeyUp(123)) then Result:=True;
      if(Num=13) and (KeyUp(124)) then Result:=True;
      if(Num=14) and (KeyUp(125)) then Result:=True;
      if(Num=15) and (KeyUp(126)) then Result:=True;
      if(Num=1) and  not (KeyUp(112)) then Result:=False;
      if(Num=2) and  not (KeyUp(113)) then Result:=False;
      if(Num=3) and  not (KeyUp(114)) then Result:=False;
      if(Num=4) and  not (KeyUp(115)) then Result:=False;
      if(Num=5) and  not (KeyUp(116)) then Result:=False;
      if(Num=6) and  not (KeyUp(117)) then Result:=False;
      if(Num=7) and  not (KeyUp(118)) then Result:=False;
      if(Num=8) and  not (KeyUp(119)) then Result:=False;
      if(Num=9) and  not (KeyUp(120)) then Result:=False;
      if(Num=10) and  not (KeyUp(121)) then Result:=False;
      if(Num=11) and  not (KeyUp(122)) then Result:=False;
      if(Num=12) and  not (KeyUp(123)) then Result:=False;
      if(Num=13) and  not (KeyUp(124)) then Result:=False;
      if(Num=14) and  not (KeyUp(125)) then Result:=False;
      if(Num=15) and  not (KeyUp(126)) then Result:=False;
    end;

    I have always had trouble with KeyUps and KeyDowns. The only way i could get them to type were by using GetKeyCode(' ').
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  4. #4
    Join Date
    Jul 2007
    Location
    St. Louis, Missouri, USA.
    Posts
    575
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    For that, I'd suggest using a case or maybe a for loop. Would save so much space and memory.
    -You can call me Mick-



  5. #5
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by mickaliscious View Post
    For that, I'd suggest using a case or maybe a for loop. Would save so much space and memory.
    What? Like this?:
    SCAR Code:
    function IsFKeyUp(Num: Byte): Boolean;
    var i,p: integer;
    begin
      for p:=1 to 30 do
      for i:=112 to 126 do
        if(Num=p) and (KeyUp(i)) then Result:=True;
        if(Num=p) and not(KeyUp(i)) then Result:=False;
      end;
      end;
    end;

    But you still get the type mismatch in script.
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  6. #6
    Join Date
    Jul 2007
    Location
    St. Louis, Missouri, USA.
    Posts
    575
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Could do something like:
    SCAR Code:
    function IsFKeyUp(Num: Byte): Boolean;
    begin
      Result := not IsFKeyDown(Num);
    end;
    -You can call me Mick-



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

    Default

    KeyUp is a procedure that releases a key. If you're checking to see if a key is not pressed, use (not(IsKeyDown(chr(CodeHere))))

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. Syntax error in script
    By plaxlord in forum OSR Help
    Replies: 5
    Last Post: 01-31-2008, 07:39 AM
  4. Editors with Syntax highlighting?
    By 2nd-protocol in forum News and General
    Replies: 5
    Last Post: 06-26-2007, 12: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
  •