{ Joao Paulo Schwarz Schuler }
{ Fonte em POO para Pasacal que divide uma string em palavras }
{ Pascal source that divide a string in words }
type TSTR20 = string[20];
type TSeparador = object
{ Divide string em palavras }
{ Divides a string in words }
P: array[0..20] of TSTR20; { PALAVRAS } { words }
NP: byte; {Numero de palavras }
{Number of words }
procedure Sepal(LINHA:string);
{ separa linha em palavras }
{ Divide the line string in words }
function GetP(NUM:byte):TSTR20;
{ devolve palavra de indice Num }
{ return the word indexed by Num }
function GetNP:byte;
{ devolve numero de palavras }
{ return how many words there }
procedure UpCaseAll;
{ Executa UpCase em todas as palavras }
{ Execute UpCase in all words }
end;
procedure TSeparador.Sepal(LINHA:string);
{ separa linha em palavras }
var A:word;
L:char; {LETRA}
begin
for A:=1 to 20
do P[A]:='';
L:=' ';
NP:=1;
for A:=1 to length(LINHA) do
begin
L:=LINHA[A];
if (L<>' ') then
begin
P[NP]:=P[NP]+L
end
else
begin
if (LINHA[pred(A)]<>' ') and (A<>1) and (NP<20) then
begin
inc(NP);
end
end
end; { of for }
if P[NP]='' then dec(NP);
end;
function TSeparador.GetP(NUM:byte):TSTR20;
{ devolve palavra de indice Num }
begin
GetP:=P[NUM];
end;
function TSeparador.GetNP:byte;
{ devolve numero de palavras }
begin
GetNP:=NP;
end;
procedure TSeparador.UpCaseAll;
{ Executa UpCase em todas as palavras }
var Palavra,Caracter:word;
begin
for Palavra:=1 to NP do
for Caracter:=1 to length(P[Palavra]) do
P[Palavra][Caracter]:=UpCase(P[Palavra][Caracter]);
end;
var TS:TSeparador;
I:Integer;
begin
TS.SePal('Este e um exemplo.');
for I:=1 to TS.GetNP do
writeln(I:3,':',TS.GetP(I));
TS.SePal('This is a example.');
TS.UpCaseAll;
for I:=1 to TS.GetNP do
writeln(I:3,':',TS.GetP(I));
end.
Return to the Home Page
I want to read your E-Mail