domingo, 13 de setembro de 2009

Obtendo a Posição Inicial da Próxima palavra após o caractere indicado por 'InitPos'

Function NextPosWord (S : ShortString; InitPos, Mode : Byte) : Byte;
Var
I : Integer;
Begin
InitPos := Min (Max (InitPos, 1), Length(S));
if Mode = mdDescend Then
I := -1
else
I := 1;
while ((InitPos <= Length(S)) And (InitPos > 0) And (S[InitPos] <> ' ')) Do
Inc (InitPos, I);
while ((InitPos <= Length(S)) And (InitPos > 0) And (S[InitPos] = ' ')) Do
Inc (InitPos, I);
if InitPos > Length (S) Then
InitPos := 0;
NextPosWord := InitPos;
End;

Nenhum comentário:

Postar um comentário