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
Cruciverba - lima.pas

lima.pas

Caricato da: Poggi Marco
Scarica il programma completo

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