Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Pessoal é o seguinte, tenho este sistema em pascal que tem como funcao :
Cadastrar registros, pesquisar registro, classificar por ordem de nomes, apresentar todos, e sair do
programa, segue abaixo o source:
program Cap9_a;
uses crt;
const n = 3;
type
Agenda = record
nome : string;
ender : string;
tel : string;
end;
var
Registro : array[1..10] of Agenda;
i, opt : integer;
procedure Cadastrar;
begin
for i:=1 to n do
begin
clrscr;
write('Cadastro de Registros');
writeln;
writeln;
write('Nome [',i,'] : ');
read(Registro[i].nome);
writeln;
write('Endereco [',i,'] : ');
read(Registro[i].ender);
writeln;
write('Telefone [',i,'] : ');
read(Registro[i].tel);
writeln;
readkey;
end;
write('Aperte qualquer tecla para voltar ao Menu...');
readkey;
end;
procedure Pesquisar;
var
Pesq, Aux : string;
Controle, Achou: Boolean;
begin
Controle:=True;
Achou:=False;
repeat
clrscr;
write('Pesquisa de Registros');
writeln;
writeln;
write('Especifique o Nome a ser Pesquisado : ');
read(Pesq);
writeln;
write('Procurando por ',Pesq,'.....');
writeln;
writeln;
for i:=1 to n do
begin
if (Pesq = Registro[i].nome) then
begin
writeln;
Achou:=True;
write('O termo [',Pesq,'], foi encontrado no Indice [',i,']');
writeln;
break;
end
else
writeln('--- Indice [',i,'] nao confere! ---');
end;
writeln;
if (Achou = True) then
begin
writeln;
write('Resultado da Pesquisa :');
writeln;
writeln;
write('Nome : ',Registro[i].nome);
writeln;
write('Endereco : ',Registro[i].ender);
writeln;
write('Telefone : ',Registro[i].tel);
writeln;
Achou:=False;
end
else
writeln('Sua pesquisa nao obteve resultados,..');
writeln;
write('Deseja efetuar nova pesquisa ? (S/N) ');
read(Aux);
if ((Aux = 'S') or (Aux = 's')) then
Controle:=True
else
Controle:=False;
until Controle = False;
readkey;
end;
procedure Classificar;
var
posMenor, j : integer;
tmp: string;
begin
clrscr;
for i:=1 to n-1 do
begin
posMenor:=i;
for j:=i+1 to n do
if Registro[j].nome < Registro[posMenor].nome then
posMenor := j;
if i <> posMenor then
begin
tmp := Registro[i].nome;
Registro[i].nome := Registro[posMenor].nome;
Registro[posMenor].nome := tmp;
end;
end;
writeln;
writeln('Ordenacao por Nomes : ');
for i:=1 to n do
begin
writeln;
writeln(Registro[i].nome);
end;
writeln;
writeln('Pressione qualquer tecla para voltar ao Menu');
readkey;
end;
procedure ApresentarTodos;
begin
clrscr;
for i:=1 to n do
begin
writeln;
write('Nome [',i,'] : ');
write (Registro[i].nome);
writeln;
write('Endereço [',i,'] : ');
write (Registro[i].ender);
writeln;
write('Telefone [',i,'] : ');
write (Registro[i].tel);
writeln;
end;
readkey;
end;
begin
opt:=0;
while not (opt = 5) do
begin
clrscr;
writeln('Agenda Menu');
writeln;
write('1 : Cadastrar [',n,' registros]');
writeln;
write('2 : Pesquisar Registro');
writeln;
write('3 : Classificar por Nome');
writeln;
write('4 : Listar Todos os Registros');
writeln;
write('5 : Sair');
writeln;
writeln;
write('Opcao : ');
read(opt);
writeln;
case opt of
1:Cadastrar;
2:Pesquisar;
3:Classificar;
4:ApresentarTodos;
5: begin writeln; write('Saindo...'); readkey; end;
else
begin
writeln('A opcao especificada nao existe!');
readkey;
end;
end;
end;
end.
quando compilo no pascalzim, ele roda bacana, mas quando tento rodar no dev-pascal ou free pascal
ele não obedece a leitura dos parametros, no caso do laço for de cadastrar, ele nao me deixa inserir os dados referente ao 1° registro antes de pedir o proximo,ele simplesmente já pula pro ultimo e so me resta apertar a tecla e voltar pro menu, continuando com os vetores limpos,
assim acontece tbm nos outros procedures que tem laços,..
mais uma coisa, alguem sabe como faço pra utilizar uma unit minha mesmo no pascalzim, ?
no dev-pascal ou free pascal, foi so chamar a unit pelo nome estando na mesma pasta, ja no pascalzim nao dá certo! tá meio dificil conseguir sanar estas dúvidas, se alguem puder me ajudar agradeço muito,...
abraço!
Carregando comentários...