Results 1 to 4 of 4

Thread: How to make variable equel letters?

  1. #1
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default How to make variable equel letters?

    I tried making a status for my fighting script but i get an error.. the code looks like:
    Simba Code:
    status1 := ('Attacking ');
        WriteLn('' + IntToStr(status1) + IntToStr(monsterkill) + '!');
    I get the error:
    Code:
    [Error] C:\Users\*\Desktop\simba\Combat\Soulsplit autofighter.simba(108:29): Type mismatch at line 107
    I declared status1 in main variable section

  2. #2
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Simba Code:
    program test;
    {$i srl/srl.simba}

    var
      // how to declare a variable that stores a string var
      message: string;
      MonsterKill: integer;

    begin
      setupsrl;
      // how to use the string var
      message := 'Attacking';
      // don't need to convert the message as it is already a string type
      writeln('' + message + IntToStr(MonsterKill) + '!');
    end.

    hope that helps clear it up. Note you should have declared the Monsterkill variable as an integer prior to use.

  3. #3
    Join Date
    Jul 2012
    Posts
    279
    Mentioned
    5 Post(s)
    Quoted
    46 Post(s)

    Default

    IntToStr stands for "Integer To String". It is a way to transform an integer into a string as writeln only writes down variables that can be string (let's keep it simple and ignore other variables for now). There is no need to transform status1 as it's already a string. With the line, you're trying to use it as a integer, therefore getting a type mismatch.

  4. #4
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Thanks works great!

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
  •