Results 1 to 13 of 13

Thread: type mismatch

  1. #1
    Join Date
    Oct 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default type mismatch

    Hi, I am having a problem involving constants. In the beginning of my program I have this:
    SCAR Code:
    const
         Time = 14;

    and then later on when I try to do this:
    SCAR Code:
    Wait(Time * 1000);

    It gives me a type mismatch error. I guess it has something to do with casting maybe but I'm not sure how to fix it.

  2. #2
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    Var Time : integer;

    Begin
      Time := 14;
      Wait((Time*1000))
    end.

    You need a Var Not Const

  3. #3
    Join Date
    Oct 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I know but how can I keep it up at the top then so it can be changed easily by the user?

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

    Default

    Lol timer, ofcourse you can use a const, you need a 'middleman' there.

    Look, keep your const, and make a new global variable called TheTime.

    In the beginning of your mainloop, do TheTime := Time;

    Then you can use it like Wait(TheTime) Etc..

    EDIT: Weird thing is that String Consts can be used straight?

  5. #5
    Join Date
    Oct 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yea that code makes no sense because why would you be able to assign Time to TheTime if you can't pass it into a procedure that takes an int? I tried it out anyway and I still got the error except it was in the line 'TheTime := Time;'

  6. #6
    Join Date
    Oct 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I just tried using StrToInt(Time) and it still did not work, even when I changed the const declaration to

    const
    Time = '14';

  7. #7
    Join Date
    Mar 2007
    Location
    Netherlands->Amersfoort.
    Posts
    1,615
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program New;
    const
      WaitTime = 4;

    begin
      Wait((WaitTime * 1000));
    end.

    the problem where the names of you're vars. those names are used in scar

  8. #8
    Join Date
    Oct 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Wow thanks a lot! I thought I would have gotten a duplicate identifier error if that happens but now it seems to compile

  9. #9
    Join Date
    Oct 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I have another type mismatch problem that I cannot figure out.

    In my DeclarePlayer I have this:
    SCAR Code:
    Players[0].Name :='USERNAME1';
         Players[0].Pass :='PASSWORD1';
         Players[0].Nick :='';
         Players[0].Skill:='auto'; // Set attack, defense, strength, or auto.
         Players[0].Active:=True;

    but for some reason this gives me a type mismatch:
    SCAR Code:
    procedure ChooseFightStyle;
    begin
         if not Players[CurrentPlayer].Skill = 'auto' then
              SetFightStyle(Players[CurrentPlayer].Skill)
         else
              SetFightStyle(GetLowestSkill);
    end;

  10. #10
    Join Date
    Mar 2007
    Location
    Netherlands->Amersfoort.
    Posts
    1,615
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    probebly the same as before so make it:

    SCAR Code:
    Players[0].Name :='USERNAME1';
         Players[0].Pass :='PASSWORD1';
         Players[0].Nick :='';
         Players[0].Strings[0] :='auto'; // Set attack, defense, strength, or auto.
         Players[0].Active:=True;

    SCAR Code:
    procedure ChooseFightStyle;
    begin
         if not Players[CurrentPlayer].strings[0] = 'auto' then
              SetFightStyle(Players[CurrentPlayer].strings[0])
         else
              SetFightStyle(GetLowestSkill);
    end;

    otherwise can you say on with line the error is?

  11. #11
    Join Date
    Oct 2007
    Posts
    37
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hmm... nope it still is not working. The error is:
    [Runtime Error] : Type Mismatch in line 169 in script C:\Users\Max\Documents\SCAR\Chicken Killer\Chicken Killer V2.scar
    SCAR Code:
    procedure ChooseFightStyle;
    begin
         if not Players[CurrentPlayer].Strings[0] = 'auto' then  // <---- Line 169
              SetFightStyle(Players[CurrentPlayer].Strings[0])
         else
              SetFightStyle(GetLowestSkill);
    end;

  12. #12
    Join Date
    Mar 2007
    Location
    Netherlands->Amersfoort.
    Posts
    1,615
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    i don't get that error >,<
    i maby know why,, anyway try this:

    SCAR Code:
    procedure ChooseFightStyle;
    begin
      case LowerCase(Player[currentplayer].strings[0]) of
        'auto'    : SetFightStyle(GetLowestSkill);
        'attack'  : SetFightStyle('attack');
        'defence' : SetFightStyle('defence');
        'strength': SetFightStyle('strength');
      end;
    end;

    edit: have you allready tryed to give it a other name?
    like ChooseTheFightStyle; ?

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

    Default

    I see nothing wrong with your line 169 and company.
    ~ Metagen

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Type Mismatch...
    By Raskolnikov in forum OSR Help
    Replies: 3
    Last Post: 10-18-2008, 05:56 AM
  2. Type mismatch
    By batnas in forum OSR Help
    Replies: 3
    Last Post: 04-24-2008, 06:48 PM
  3. Type Mismatch..
    By Nava2 in forum OSR Help
    Replies: 1
    Last Post: 04-23-2008, 07:44 PM
  4. Type mismatch Help
    By Ashur2Good in forum OSR Help
    Replies: 2
    Last Post: 05-23-2007, 03:47 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
  •