Program na čítanie/zápis čísel z/do súboru

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Kategória: KMP (Klub mladých programátorov)

Program: Cisla_subor.pas
Súbor exe: Cisla_subor.exe

Program na čítanie/zápis čísel z/do súboru.
{ cisla_subor.pas                                                    }
{ Program na citanie/zapis cisel z/do suboru.                        }
{                                                                    }
{ Author: ghostix                                                    }
{ Datum:20.04.2005                              http://www.trsek.com }
program progcisla; 
uses  crt; 
var   F:file of integer; 
      ODP:char; 
 
procedure VSTUP; 
  var FM:string[12]; 
      X:integer; 
  begin 
  write('Meno suboru na disku: '); 
  readln(FM); 
  assign(F,'C:\data\');
  rewrite(F); 
  repeat 
    write('Vlozit cislo: '); 
    readln(X); 
    write(F,X); 
    writeln('Vlozit dalsie cislo (nie - N) ?':52); 
  until upcase(readkey)='N'; 
  close(F); 
  end; 
 
procedure VYSTUP; 
  var FM:string[12]; 
      X:integer; 
  begin 
  write('Meno suboru na disku: '); 
  readln(FM); 
  assign(F,FM); 
  reset(f); 
  while not eof(F) do
    begin 
    read(F,X); 
    write(X:4); 
    end; 
  close(F); 
  readln 
  end; 
 
BEGIN 
repeat 
  clrscr; 
  gotoxy(1,10); 
  writeln('Vytvorit subor ............... V':50); 
  writeln; 
  writeln('Zobrazit subor ............... Z':50); 
  writeln; 
  writeln('Koniec ....................... K':50); 
  repeat ODP:=upcase(readkey); until (ODP='V')or(ODP='Z')or(ODP='K');  
  clrscr; 
  case ODP of 
    'V' : VSTUP; 
    'Z' : VYSTUP; 
  end 
until ODP='K' 
END.