Results 1 to 6 of 6

Thread: Another type mismatch. (converting variables)

  1. #1
    Join Date
    Sep 2008
    Posts
    155
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Another type mismatch. (converting variables)

    Scar says: "[Error] (16807:36): Type mismatch in script C:\Pr[...]RTV6.scar" when i try to run my script, this is where it has trouble:

    SCAR Code:
    case (Players[CurrentPlayer].Strings[0]) of
      'mithril': begin
                 If (SmithingXP / 30) < (MagicXP / 55) then
                 begin
                   LesserXP := SmithingXP / 30;
                 end else
                   LesserXP := MagicXP / 55;
                 MithrilBarsCreated := Int(LesserXP);
                 AdamantiteBarsCreated := 0;
                 RuniteBarsCreated := 0;
                 end;

    (It has trouble with "MithrilBarsCreated := Int(LesserXP);", MithrilBarsCreated is an Integer and LesserXP is an "Extended" (aka float)).

    Any suggestions?
    Current Project - Superheater :: Mithril Bars - Should be ready for Members application soon

  2. #2
    Join Date
    Nov 2006
    Location
    'Pergamino, BA, Argentina';
    Posts
    473
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

  3. #3
    Join Date
    Sep 2008
    Posts
    155
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    no it says that's an unknown identifier, the description of Int() in the SCAR manual is:

    function Int(e: Extended): LongInt;

    Is it having an error because the function returns a LongInt and I'm storing to an Int? If so, how to I declare a LongInt?
    Current Project - Superheater :: Mithril Bars - Should be ready for Members application soon

  4. #4
    Join Date
    Sep 2008
    Posts
    155
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I think you declare a LongInt just by LongInt, but I still doesn't work. I can get it to work if I round() instead of int(), but I still would like to fix this for future reference, if anyone knows why.

    EDIT: Sorry for double post, they're pretty different/use each other so that why =/
    Current Project - Superheater :: Mithril Bars - Should be ready for Members application soon

  5. #5
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Int64, Int and LongInt are different but in SCAR declaring as Integer will cover them all.
    Ce ne sont que des gueux


  6. #6
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    Call all integers Integer, and use the Round() function to convert extended over. Its easier, but if you need them to be converted other wise use:

    Quote Originally Posted by ScarManual
    function Floor(X: Extended): Integer;
    Rounds down X to the lowest integer.
    Example:
    Floor(5.4) = 5

    function Ceil(X: Extended): Integer;
    Rounds down X to the highest integer.
    Example:
    Ceil(5.4) = 6
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

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 batnas in forum OSR Help
    Replies: 3
    Last Post: 04-24-2008, 06:48 PM
  2. Type Mismatch..
    By Nava2 in forum OSR Help
    Replies: 1
    Last Post: 04-23-2008, 07:44 PM
  3. type mismatch
    By drizzt in forum OSR Help
    Replies: 2
    Last Post: 02-16-2008, 03:19 PM
  4. type mismatch help
    By 1-DUB in forum OSR Help
    Replies: 5
    Last Post: 05-27-2007, 05: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
  •