Pascal/Turbo Pascal - TRATAMIENTO DE ARCHIVOS

 
Vista:

TRATAMIENTO DE ARCHIVOS

Publicado por Antonio (74 intervenciones) el 21/07/2014 17:31:52
Hola. He de realizar el siguiente trabajo en tratamiento de archivos: Hacer un programa que iguale las líneas de texto de un archivo. Después de varios intentos sin lograrlo,pero sí lo compila, les paso el código fuente del último intento:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
program Iguala_lineas_de_texto;
uses    crt,wincrt;
 
var
        car      : char;
        palabra  : string;
        f1,f2    : text;
 
 
begin
 
 
        Assign(f1,'Archivo1.pas');
        Reset(f1);
        assign(f2,'Prueba20.txt');
        rewrite(f2);
 
        while not eof(f1) do
        begin
          while not eoln(f1) do
          begin
          read(f1,car);
          if (length(palabra)<=70)and(ord(car)=13) then
            delete(Palabra,length(palabra),1);
            if length(palabra) > 70 then
            writeln(f2)
          else
          write(f2,car);
          end;
          writeln(f2);
        end;
        close(f1);
        close(f2);
end.


Muy agradecido por la ayuda que me puedan prestar.
Un saludo.
Antonio.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

TRATAMIENTO DE ARCHIVOS

Publicado por ramón (2 intervenciones) el 24/07/2014 13:51:12
Mira los blancos los modifico para que lo compruebes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
program Iguala_lineas_de_texto;
 uses
   crt;
 const
  lonlinea = 60;
 var
   car      : char;
   palabra  : string;
   f1,f2    : text;
   bla, cont     : integer;
   begin
        Assign(f1,'Archivo1.pas');
        {$I-} Reset(f1); {$I+}
        if ioresult <> 0 then
        begin
          writeln('  Error de archivo pulse una tecla');
          readkey;
        end
     else
        begin
        assign(f2,'Prueba20.txt');
        rewrite(f2);
        writeln(f2,'Todas Las Lineas A ',lonlinea,' Caracteres');
        close(f2);
        cont := 1;
        while not eof(f1) do
        begin
          read(f1,car);
          if (car = ' ') or (car = chr(10)) or (car = chr(13)) then
          car := '-';
          palabra[cont] := car;
          palabra[0] := chr(cont);
          cont := cont + 1;
          if cont > lonlinea then
          begin
             Append(f2);
             writeln(f2,palabra);
             close(f2);
             cont := 1;
          end;
      end;
        if cont > 1 then
        begin
        Append(f2);
        writeln(f2,palabra);
        close(f2);
        end;
     end;
        close(f1);
    end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar

TRATAMIENTO DE ARCHIVOS

Publicado por Antonio (74 intervenciones) el 25/07/2014 19:47:48
Hola, Ramón. Muy agradecido por la aclaración. Pues, la verdad sea dicha, me cuesta un poco entender el tratamiento de los archivos.
Un saludo.
Antonio.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar