{ TSsPlayTime Component - Estimates SakuraScript playing time }
{ }
{ Copyright (c) 2001-2003 naruto/CANO-Lab }
+{ (c) 2001-2005 WinBottle Project }
{*************************************************************}
unit SsPlayTime;
procedure TSsPlayTime.CountCharacterType(const Str: String; out SB,
DB, SPNum, SPWait: integer);
var
- i, j: integer;
+ i, j, lnStr: integer;
InLeadByte, Flag: boolean;
AChar: TSsPlayTimeSpecialChar;
begin
SPNum := 0;
SPWait := 0;
InLeadByte := false;
- for i := 1 to Length(Str) do
+ lnStr := Length(Str);
+ for i := 1 to lnStr do
begin
if InLeadByte then
begin
for j := 0 to PlayTimeParams.SpecialChars.Count-1 do
begin
AChar := PlayTimeParams.SpecialChars.Items[j] as TSsPlayTimeSpecialChar;
- if Length(AChar.Char) = 2 then
+ if (Length(AChar.Char) = 2) and (lnStr-i > 0) then
begin
if Str[i] + Str[i+1] = AChar.Char then
begin