Results 1 to 3 of 3

Thread: Out of range

  1. #1
    Join Date
    Dec 2011
    Posts
    124
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Out of range

    Simba Code:
    procedure DeclareVars;
    Var
      i, ii: Integer;
    begin
      ClearDebug;
      SetLength(plankType, Length(players[CurrentPlayer].Arrays[0]));
      ii := Length(plankType);
      for i := 0 to ii do
        Writeln(Capitalize(players[CurrentPlayer].Name +  ' is making '  + players[CurrentPlayer].Arrays[0][i] +  ' planks.'));
    end;
    I'm getting an out of range error on:
    Simba Code:
    Writeln(Capitalize(players[CurrentPlayer].Name +  ' is making '  + players[CurrentPlayer].Arrays[0][i] +  ' planks.'));

    It does everything it's supposed to do, but once done doing that, the script will stop.

  2. #2
    Join Date
    Nov 2011
    Location
    Jozi, South Africa
    Posts
    249
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Arrays count from zero. The Length function counts from 1. Change ...

    Simba Code:
    for i := 0 to ii do

    to this ...

    Simba Code:
    for i := 0 to ii - 1 do


    EDIT: No problem. You're welcome. (BTW: We all go there at some stage - newbie or old timer! )
    Last edited by NickMystre; 01-31-2012 at 08:28 AM.
    Ciao
    NM

  3. #3
    Join Date
    Dec 2011
    Posts
    124
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NickMystre View Post
    Arrays count from zero. The Length function counts from 1. Change ...

    Simba Code:
    for i := 0 to ii do

    to this ...

    Simba Code:
    for i := 0 to ii - 1 do
    Ahh, nice catch, didn't see that one .

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
  •