Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Indirizzi - lima.pas

lima.pas

Caricato da: Poggi Marco
Scarica il programma completo

  1. unit lima;
  2.  
  3. { unita per gestire i file di testo}
  4.  
  5. interface
  6.  
  7. type tlima=object
  8.  private
  9.   lima:text;
  10.   percorso:string;
  11.   apertura:char;
  12.  public
  13.   function ApriFile(nome:string; modo:char):boolean;
  14.   procedure scrivi(fr:string);
  15.   procedure ScriviLn(fr:string);
  16.   function leggi:string;
  17.   function fine:boolean;
  18.   function GetNomeFile:string;
  19.   procedure ChiudiFile;
  20. end;
  21.  
  22. // function cartella:string;
  23.  
  24. implementation
  25. // uses dos;
  26.  
  27. function tlima.ApriFile(nome:string; modo:char):boolean;
  28. var ch:boolean;
  29. begin
  30.  percorso:=nome;
  31.  ch:=true;
  32.  apertura:=UpCase(modo);
  33.  case apertura of
  34.   'W': begin
  35.         assign(lima, percorso);
  36.         {$I-}
  37.          rewrite(lima);
  38.         {$I+}
  39.         ch:=(IOResult=0);
  40.        end;
  41.   'A': begin
  42.         assign(lima, percorso);
  43.         {$I-}
  44.          append(lima);
  45.         {$I+}
  46.         ch:=(IOResult=0);
  47.        end;
  48.   'R': begin
  49.         assign(lima, percorso);
  50.         {$I-}
  51.          reset(lima);
  52.         {$I+}
  53.         ch:=(IOResult=0);
  54.        end;
  55.   else ch:=false;
  56.  end; // fine case  of
  57.  if not ch then apertura:='X';
  58.  ApriFile:=ch;
  59. end;
  60.  
  61. procedure tlima.scrivi(fr:string);
  62. begin
  63.  if (apertura='W') or (apertura='A') then
  64.  begin
  65.    write(lima, fr);
  66.  end;
  67. end;
  68.  
  69. procedure tlima.ScriviLn(fr:string);
  70. begin
  71.  if (apertura='W') or (apertura='A') then
  72.  begin
  73.    write(lima, fr+#13+#10);
  74.  end;
  75. end;
  76.  
  77. function tlima.fine:boolean;
  78. begin
  79.  if (apertura='W') or (apertura='A') or (apertura='R') then
  80.  begin
  81.    fine:=EOF(lima);
  82.  end
  83.  else
  84.  begin
  85.   fine:=true;
  86.  end;
  87. end;
  88.  
  89. function tlima.GetNomeFile:string;
  90. begin
  91.  GetNomeFile:=percorso;
  92. end;
  93.  
  94. procedure tlima.ChiudiFile;
  95. begin
  96.  if (apertura='W') or (apertura='A') or (apertura='R') then
  97.  begin
  98.   close(lima);
  99.   apertura:='X';
  100.  end;
  101. end;
  102.  
  103. function tlima.leggi:string;
  104. var fr:string;
  105. begin
  106.  fr:='';
  107.  if apertura='R' then
  108.  begin
  109.    readln(lima, fr);
  110.  end;
  111.  leggi:=fr;
  112. end;
  113.  
  114. function cartella:string;
  115. var borsa:string;
  116. begin
  117.  GetDir(0, borsa);
  118.  cartella:=borsa;
  119. end;
  120.  
  121.  
  122. begin
  123.  
  124. end.