Thank you, I'll try the ide sometime.
To agree with the sysutils method I have altered my previous tally routine although I have cranked up the goto's in the process.
program tally;
Type
intArray = Array of integer;
// ========= number of partstring in somestring =============//
function tally(somestring:pchar;partstring:pchar;out arr: intarray ):integer;
var
i,j,ln,lnp,count,num:integer ;
filler:boolean;
label
skip ,start,return;
begin
ln:=length(somestring);
lnp:=length(partstring);
filler:=false;
start:
count:=0;
i:=-1;
repeat
i+=1;
if somestring[i] <> partstring[0] then goto skip ;
if somestring[i] = partstring[0] then
begin
for j:=0 to lnp-1 do
begin
if somestring[j+i]<>partstring[j] then goto skip;
end;
count+=1;
if filler = true then arr[count]:=i+1 ;
i:=i+lnp-1;
end ;
skip:
until i>=ln-1 ;
SetLength(arr,count); // size is now known, repeat the operation to fil arr
arr[0]:=count; // save tally in [0]
num:=count;
if filler=true then goto return;
filler:=true;
goto start;
return:
result:=num;
end; {tally}
//=========== Trial =========== //
var
arr:intarray;
p:pchar;
s:ansistring;
i,num:integer;
comma:string;
begin
s:='abababababab';
for i:=1 to 5 do
begin
s+=s;
end;
p:=pchar(s); // cast
writeln(s);
num:=tally(p,'aba',arr);
writeln('Tally of aba ',num);
write('string length = ');
writeln(length(p));
writeln('Positions:');
for i:=1 to arr[0] do
begin
if i<arr[0] then comma:=',' else comma:='';
write(arr[i],comma);
end;
writeln;
writeln('Press enter to end');
readln;
end.