Each string from the new string, text formatter w/ Pascal

(*) fast dirty  version, but it is works!

var
f1: file of Char;
f2: file of Char;
i:longint;
j:longint;
c:char;
begin
J:=0;
Assign(f1,’text.txt’);
reset(f1);
Assign(f2,’mytext.txt’);
rewrite(f2);

for i:=1 to Filesize(f1) do
begin
read(f1,c);
write(f2,c);
if ord(c)=46 then
begin
write(f2,chr(13));
read(f1,c);
end;
end;
close(f1);
close(f2);

end.

Advertisements

Counting characters from file

(*) any Pascal, no units (46 = dot code, 13 = new line break)

var
f1: file of Char;
i:longint;
j:longint;
c:char;
begin
J:=0;
Assign(f1,’out.csv’);
reset(f1);
for i:=1 to Filesize(f1) do
begin
read(f1,c);
if ord(c)=59 then j:=j+1;
end;
close(f1);
writeln(j);
end.

Ancient names generator code on any Pascal

Mine copylefts, comrades =)

var
a: array[0..20] of string;
b: array[0..20] of string;
s: string;
begin
a[0]:=’man’;
a[1]:=’phil’;
a[2]:=’fil’;
a[3]:=’bor’;
a[4]:=’vor’;
a[5]:=’wor’;
a[6]:=’sor’;
a[7]:=’dor’;
a[8]:=’tor’;
a[9]:=’ham’;
a[10]:=’sim’;
a[11]:=’sar’;
a[13]:=’fart’;
a[12]:=’hin’;
a[14]:=’min’;
a[15]:=’mun’;
a[16]:=’lov’;
a[17]:=’mud’;
a[18]:=’rast’;
a[19]:=’zar’;
a[20]:=’fard’;

b[0]:=’Theo’;
b[1]:=’Teo’;
b[2]:=’Vole’;
b[3]:=’Rava’;
b[4]:=’Volend’;
b[5]:=’Ra’;
b[6]:=’Ole’;
b[7]:=’Iri’;
b[8]:=’Rafi’;
b[9]:=’Ele’;
b[10]:=’Aro’;
b[11]:=’Ara’;
b[13]:=’Doro’;
b[12]:=’Ere’;
b[14]:=’Pere’;
b[15]:=’Octo’;
b[16]:=’Repe’;
b[17]:=’Toro’;
b[18]:=’Thoro’;
b[19]:=’Sara’;
b[20]:=’Sa’;

s:=”;
randomize;
s:=b[random(20)];
randomize;
s:=s+a[random(20)];
Writeln(s);
s:=s+’ka’;
Writeln(s);
end.