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
/
ENTERPRS
/
CPM
/
UTILS
/
A
/
BYTETURB.ARC
/
STRINGS.LIB
< prev
next >
Wrap
Text File
|
1989-09-27
|
2KB
|
96 lines
{$R-} { turn off range checking (if on) }
{$V-} { turn off string parm length checking }
{
procedures and functions in this library
LowToUp converts string to uppercase
Strip removes any leading characters
Parse gets next word out of string
Replace replaces all instance of one substring with another
}
type
bigstr = string[255];
setofchar = set of char;
procedure lowtoup(var tstr : bigstr);
{
purpose converts TStr to all upper case
last update 23 Jun 85
}
var
len,indx : integer;
begin
len := length(tstr);
for indx := 1 to len do
tstr[indx] := upcase(tstr[indx])
end; { of proc LowToUp }
procedure strip(var line : bigstr; var len : integer; break : setofchar);
{
purpose pull out all chars in Break from start of Line
last update 09 Jul 85
}
var
indx : integer;
begin
len := length(line);
if len > 0 then begin
indx := 0;
while (line[indx+1] in break) and (indx < len) do
indx := indx + 1;
delete(line,1,indx);
len := len - indx;
end
end; { of proc Strip }
procedure parse(var line,word : bigstr; break : setofchar);
{
purpose removes first word in Line and returns it in Word
last update 23 Jun 85
}
var
len,indx : integer;
begin
word := '';
strip(line,len,break);
if len = 0
then exit;
indx := 0;
while not (line[indx+1] in break) and (indx < len) do
indx := indx + 1;
word := copy(line,1,indx);
delete(line,1,indx);
strip(line,len,break)
end; { of proc Parse }
procedure replace(var target : bigstr; oldstr,newstr : bigstr; maxlen : byte);
{
purpose look for all instances of OldStr and replace with NewStr
last update 09 Jul 85
}
var
tarlen,oldlen,inclen,indx
: integer;
begin
tarlen := length(target);
oldlen := length(oldstr);
inclen := length(newstr) - oldlen;
indx := pos(oldstr,target);
while indx > 0 do begin
if tarlen + inclen <= maxlen then begin
delete(target,indx,oldlen);
insert(newstr,target,indx);
tarlen := tarlen + inclen;
indx := pos(oldstr,target)
end
else indx := 0
end
end; { of proc Replace }
tarlen := tarlen + inclen;
indx := pos(oldstr,t