====== Creazione file di testo in pascal ====== Autore: **//Fabio Di Matteo//** \\ Ultima revisione: **//06/05/2007//** Una unit di freepascal con le principali funzioni per scrivere e leggere file di testo. unit filetesto; interface uses sysutils; type fileditesto = text; {oppure "..= file of char"} albero = ^nodo;{alla fine non usato piu'} nodo = record parola:string; figliosx:albero; figliodx:albero; end; procedure Aggiungi(testo :string); procedure Leggi(); procedure Ordina(); procedure Conta(parola :string); implementation procedure Aggiungi(testo :string); var a : fileditesto; begin assign(a,'testo.dat'); if fileExists('testo.dat') then begin reset(a); append(a); writeln(a,testo); close(a); end else begin rewrite(a); append(a); writeln(a,testo); close(a); end; end; { Createsto } procedure Leggi(); var a : fileditesto; t : string; begin assign(a,'testo.dat'); if fileExists('testo.dat') then begin reset(a); while not eof(a) do begin readln(a,t); writeln(t); end; close(a); end else begin writeln('Errore: file non presente !'); end; end; { Leggi } procedure Ordina(); var vet : array of string; c,l,i,j : integer; testo : string; a : fileditesto; begin assign(a,'testo.dat'); c:=0; l:=0; reset(a); while not eof(a) do {per vedere quante righe ha} begin readln(a,testo); c:=c+1; end; close(a); l:=c; setlength(vet,l); c:=0; reset(a); while not eof(a) do{travaso da file a vettore} begin readln(a,testo); vet[c]:=testo; c:=c+1; end; close(a); for i:=0 to l-1 do{algoritmo di ordinamneto} begin for j:=0 to l-1 do begin if vet[i]