Umístnení souboru www.TrSek.com/zadania/phonenum.pas{ PHONENUM.PAS }
{ Program vycita telefone cisla zo suboru a rozdeli podla }
{ mobilnych operatorov do suborov eurotel.txt a orange.txt }
{ }
{ Author: Juraj Pupak }
{ Date : 27.10.2006 http://www.trsek.com }
program PhoneNumbers;
uses crt;
Procedure ZapisSubor(subor : string; vytvor : Boolean; moj_text : string);
var
Tsubor : Text;
begin
Assign(Tsubor,subor);
IF vytvor = True THEN
begin
Rewrite(Tsubor);
end else
begin
Append(Tsubor);
end;
writeln(Tsubor,moj_text);
close(Tsubor);
end;
begin
clrscr;
writeln('Triedim telefone cisla podla mobilnych operatorov');
Assign(Tsubor,'PhoneNum.txt');
Reset(Tsubor);
Vytvor := True;
Vytvor_1 := True;
while not Eof(Tsubor) Do
begin
Readln(Tsubor,Cstr);
Cstr_1 := copy(Cstr,4,1);
Val(Cstr_1,Cislo,Code);
IF (Cislo >= 1) and (Cislo <= 4) THEN
begin
ZapisSubor('Eurotel.txt',Vytvor,Cstr);
Vytvor := False;
end else
begin
ZapisSubor('Orange.txt',Vytvor_1,Cstr);
Vytvor_1 := False;
end;
end;
IF Code <> 0 THEN
writeln('Error at position: ',Code);