SRL Archive - General

Simba Help With Bot


HoMoReXuaL

2012-07-03 19:47:06

Hello, im working on a bot and this is the code that i am having problems with:
repeat
PlayerName := (PlayerName + textLine[counter]);
counter:= counter+1;
until
textLine[counter] = ':';

it is supposed to get the player's name who has just spoken but as you can see, if there is no colon in a given string it will go out of bounds, which is the error i am receiving. I was wondering if there was any way to check the length of the string like in java you can use string.length , Thanks HoMo

ShawnjohnSJ

2012-07-04 01:48:07

I was going to say wrong section, but I guess its debatable. However, use code tags. (or Simba/SCAR tags)

The function you are look for I believe is called Length();


program Test;
var
Test : String;
begin
Test := 'Shawn':
Writeln(Length(Test));
end;