Pascal/Turbo Pascal - ayuda, nesesito codigos en pascal sobre archivos (file)

 
Vista:
sin imagen de perfil

ayuda, nesesito codigos en pascal sobre archivos (file)

Publicado por Habbo (4 intervenciones) el 06/05/2014 01:33:33
nesesito;
Programa para grabar en un archivo de texto “Hola, ¿cómo estás?” caracter por caracter.
Programa que lee un archivo de texto caracter por caracter.
Programa que lee un archivo de texto y muestra el número de veces que aparece cada caracter del código ASCII en dicho archivo.
Programa que lee un archivo de texto y lo graba palabra por palabra en otro.
Programa que lee un archivo de texto, cambia el contenido a mayúsculas y lo graba en otro.

ayuda Dx
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
-1
Responder
sin imagen de perfil

ayuda, nesesito codigos en pascal sobre archivos (file)

Publicado por David (224 intervenciones) el 06/05/2014 16:43:36
Aquí el primer apartado:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Uses CRT;
 
 
Var
  f : Text;
  i : integer;
  auxcad:string;
  frase:string;
 
begin
  FRASE := 'Hola, ¨c¢mo est s?';
  assign(f,'c:\hola.txt');
  {$I-} Reset(f); {$i+}
  if ioresult <> 0 then {Si no existe el fichero...}
    rewrite(f);         {... lo creamos}
 
  append(f);
  for i:=1 to length(frase) do
    begin
    auxcad:=frase[i];
    writeln(f,auxcad);
  end;
  close(F);
end.
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
sin imagen de perfil

ayuda, nesesito codigos en pascal sobre archivos (file)

Publicado por David (224 intervenciones) el 06/05/2014 16:50:43
Segundo apartado:

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
Uses CRT;
 
 
Var
  f : Text;
  i : integer;
  auxcad:string;
  frase:string;
  c:char;
 
begin
  clrscr;
  assign(f,'c:\hola.txt');
  {$I-} Reset(f); {$i+}
  if ioresult <> 0 then {Si no existe el fichero...}
    writeln('Error. El archivo buscado no existe')
  else
  begin
  Reset(F);
  while not eof(F) do
    begin
    read(f,c);
    write(c);
    end;
  end;
  close(F);
  readln;
end.
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
sin imagen de perfil

ayuda, nesesito codigos en pascal sobre archivos (file)

Publicado por Habbo (4 intervenciones) el 12/05/2014 23:03:42
gracias bro, saludos :D
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

ayuda, nesesito codigos en pascal sobre archivos (file)

Publicado por ramon (2158 intervenciones) el 06/05/2014 23:59:28
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
{Espero te sirva}
 
program maneja_texto;
 uses
   crt;
  const
     mitexto : string[17] = 'Hola ¨Como Estas?';
     archivo = 'Miarchiv.txt';
  var
    f : text;
    a : char;
    i : integer;
 
  procedure borrado_archivos;
  begin
     assign(f,archivo);
    {$I-} reset(f); {$I+}
    if ioresult = 0 then
    begin
       close(f);
       erase(f);
    end;
     assign(f,'lacopya.txt');
    {$I-} reset(f); {$I+}
    if ioresult = 0 then
    begin
       close(f);
       erase(f);
    end;
    assign(f,'mayu_pya.txt');
    {$I-} reset(f); {$I+}
    if ioresult = 0 then
    begin
       close(f);
       erase(f);
    end;
  end;
 
  procedure guardatexto;
  begin
     assign(f,archivo);
     rewrite(f);
     for i := 1 to length(mitexto) do
     begin
     write(f,mitexto[i]);
     end;
     write(f,#10#13);
     close(f);
  end;
 
  procedure leerarchivo(n : string);
  begin
     assign(f,n);
   {$I-} reset(f); {$I+}
   if ioresult <> 0 then
   begin
      writeln('   Error El Archivo No Se Encontro Pulse Una Tecla');
      readkey;
   end
  else
     begin
        while not eof(f) do
        begin
           read(f,a);
           write(a);
        end;
        close(f);
     end;
  end;
 
  procedure cuenta_caracteres(n : string);
  var
    caracteres : array[#32..#146] of integer;
    k : char;
  begin
     fillchar(caracteres,sizeof(caracteres),0);
     assign(f,n);
   {$I-} reset(f); {$I+}
   if ioresult <> 0 then
   begin
      writeln('   Error El Archivo No Se Encontro Pulse Una Tecla');
      readkey;
   end
  else
     begin
        while not eof(f) do
        begin
           read(f,a);
           caracteres[a] := caracteres[a] + 1;
        end;
        close(f);
        for k := #32 to #146 do
        if caracteres[k] > 0 then
        writeln(k,' = ',caracteres[k]);
     end;
  end;
 
  procedure copy_archivo(n : string;como : char);
  var
    f2 : text;
    i : integer;
    nu : char;
    nomb : string;
  begin
  if como = 'N' then
  nomb := 'lacopya.txt';
  if como = 'M' then
  nomb := 'mayu_pya.txt';
     assign(f,n);
   {$I-} reset(f); {$I+}
   if ioresult <> 0 then
   begin
      writeln('   Error El Archivo No Se Encontro Pulse Una Tecla');
      readkey;
   end
  else
     begin
        while not eof(f) do
        begin
         read(f,nu);
        assign(f2,nomb);
     {$I-} reset(f2); {$I+}
     if ioresult <> 0 then
     begin
        rewrite(f2);
        if como = 'N' then
        begin
        write(f2,nu);
        end;
        if como = 'M' then
         begin
           nu := upcase(nu);
           write(f2,nu);
         end;
        close(f2);
     end
   else
      begin
         append(f2);
         if como = 'N' then
         begin
         write(f2,nu);
         end;
         if como = 'M' then
         begin
           nu := upcase(nu);
           write(f2,nu);
         end;
         close(f2);
      end;
    end;
       close(f);
    end;
 end;
 
 
 
  begin
     clrscr;
     borrado_archivos;
     guardatexto;
     leerarchivo(archivo);
     writeln;
     cuenta_caracteres(archivo);
     writeln;
     copy_archivo(archivo,'N');
     leerarchivo('lacopya.txt');
     writeln;
     copy_archivo(archivo,'M');
     leerarchivo('mayu_pya.txt');
     readkey;
  end.
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
sin imagen de perfil

ayuda, nesesito codigos en pascal sobre archivos (file)

Publicado por Habbo (4 intervenciones) el 12/05/2014 23:04:39
gracias, si me sirvio de mucho :D, saludos
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