Ir ao conteúdo
  • Cadastre-se

Davidrcn

Membro Júnior
  • Posts

    1
  • Cadastrado em

  • Última visita

Reputação

0
  1. Olá, estou tentando fazer um trabalho de fundamentos de programçao, da faculdade, onde se foi pedido para criar um registro qualquer e esse registro tem que ser armazenado em um arquivo na pasya c:\prov\ , este devera gravar e fazer a leitura dos dados cadastrados e consultar, só que nas esta dando certo, ele compila mas naao abre... codigo do programa abaixo: program trabarquivo;uses crt;type clinica=record paciente:string[20]; convenio:string[15]; tel:string[14]; datacons:string[10];end; Varaux: clinica;arq_clin:file of clinica;op:char;cadastrovazio,existe:boolean;pos:longint; procedure abre_arq (nome:string);beginassign(arq_clin,'c:\prov\clinica.dat');{$I-}reset(arq_clin);{$I+}if IOResult<>0 then rewrite(arq_clin);end; procedure VerifiqueVazio (var inicio:boolean);begin inicio:=false; if filesize (arq_clin)=0 then begin inicio:=true; clrscr; writeln('Imposivel realizar opera‡Æo, cadastro vazio'); writeln('pressione qualquer tecla'); readln; end; end; procedure gravar;var r:char;begin repeat clrscr; writeln('-----Gravar Dados --------'); writeln; with aux do begin writeln('Nome do Paciente: '); readln(paciente); writeln('Convenio: ' ); readln(convenio); writeln('Telefone: '); readln(tel); writeln('Data da Consulta: '); readln(datacons); end; seek (arq_clin,filesize(arq_clin)); write(arq_clin,aux); writeln; writeln('Deseja efetuar nova inclusao? S/N '); repeat r:=upcase(readkey); until (r='S') or (r='N'); until r='N';end; procedure listartodos;begin clrscr; writeln('-------Lista de Todos ----------'); writeln; writeln('Nome':20,'convenio':15, 'telefone':12,'data':10); seek(arq_clin,0); while not eof (arq_clin) do begin read(arq_clin,aux); if aux.paciente<>'xxxx' then with aux do writeln(paciente,convenio,tel,datacons); end; writeln; writeln('pressione qualquer tecla'); readkey; end;procedure localizar (n:string; var achou:boolean; var posicao:longint);beginachou:=false;posicao:=1;seek(arq_clin,0);while not eof (arq_clin) do begin read(arq_clin,aux); if aux.paciente = n then begin achou:=true; posicao:=filepos(arq_clin) -1; end; end; end; procedure consultar;var nome:string[20]; r:char;begin repeat clrscr; writeln('-------Consulta--------'); writeln; writeln('Nome do paciente: '); readln(aux.paciente); localizar(aux.paciente,existe,pos); if existe then begin with aux do writeln('nome: ',aux.paciente); writeln('convenio: ',aux.convenio); writeln('Tel: ',aux.tel); writeln('data consulta: ',aux.datacons); end else writeln('---paciente inexistente-----'); writeln('Deseja efetuar nova consulta? S/N '); repeat r:=upcase(readkey); until (r='S') or (r='N'); until r='N'; end; begin cadastrovazio:=false; repeatclrscr;writeln('--------CLINICA MEDICA ----------'); writeln;writeln('1- Gravar Dados ');writeln('2- Consultar ');writeln('3- Listar Todos ');writeln('4-Encerrar ');writeln('Op‡Æo: ');repeat op:=readkey;until op in ['1','2','3','4'];if op in ['2','3'] thenVerifiqueVazio (CadastroVazio);if not CadastroVazio thencase op of '1':gravar; '2':consultar; '3':listartodos; end;until op='4';close(arq_clin);readkey;end.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...