home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
MBUG
/
MBUG127.ARC
/
PARSE.LBR
/
PARSE.IQC
/
PARSE.INC
Wrap
Text File
|
1979-12-31
|
2KB
|
55 lines
(* Functions to extract and count words, etc. in a text string *)
(* requires prior type declarations of AnyStr: string[255] and *)
(* CharSet: set of Char *)
function ParseCount(S: AnyStr; Delims: CharSet): Integer;
var
I, Count: Integer;
begin
I := 0;
Count := 0;
if Length(S) > 0 then
repeat
repeat
I := I + 1
until not(S[I] in Delims) or (I = Length(S));
if not(S[I] in Delims) then
Count := Count + 1;
if I < Length(S) then
repeat
I := I + 1
until (I = Length(S)) or (S[I] in Delims);
until I = Length(S);
ParseCount := Count;
end;
function ParseStr(S: AnyStr; Delims: CharSet; Num: Integer): AnyStr;
var
I, Count: Integer;
TempStr: AnyStr;
begin
I := 0;
Count := 0;
TempStr := '';
if Length(S) > 0 then
while Count < Num do
begin
repeat
I := I + 1
until not(S[I] in Delims) or (I = Length(S));
if not(S[I] in Delims) then
Count := Count + 1;
if Count < Num then
repeat
I := I + 1
until (I = Length(S)) or (S[I] in Delims);
end;
repeat
TempStr := TempStr + S[I];
I := I + 1;
until (S[I] in Delims) or (I > Length(S));
ParseStr := TempStr;
end;