Pascal/Turbo Pascal - necesito modificar es registro a un archivo

 
Vista:
sin imagen de perfil

necesito modificar es registro a un archivo

Publicado por manuel (4 intervenciones) el 08/02/2015 00:52:31
tengo que modificar este registro
de tal forma que el programa pueda
crear el archivo curso.dat e imcorporar las siguientes
opciones

1. insertar registros de cursos
2. buscar un curso por su nombre
3. buscar y mostrar cuantos cursos coordina un profesor


aqui esta el registro que tengo que modificar



program procesacurso;
uses crt;
const
M=5;
type
tipdatper=record
nombre,ci,tlf,dir:string;
end;
tipdatac=record
prof:string;
aexp:integer;
end;

tipmod=record
nombre:string;
horas:integer;
profe:record
datper:tipdatper;
datac:tipdatac;
end;
end;

tipcurso=record
nomb:string;
costo:real;
coord:record
datper: tipdatper;
datac: tipdatac;
end;
modulo:array [1..M] of tipmod

end;

arcurso=file of tipcurso;
var
c:arcurso;
curso:tipcurso;
i:integer;
opc:char;

procedure limpiar(var curso:tipcurso);
begin
curso.costo:=0;
curso.nomb:='';
curso.coord.datper.nombre:='';
curso.coord.datper.ci:='';
curso.coord.datper.tlf:='';
curso.coord.datper.dir:='';
curso.coord.datac.prof:='';
curso.coord.datac.aexp:=0;

for i:=1 to M do
begin
curso.modulo[i].nombre:='';
curso.modulo[i].horas:=0;
curso.modulo[i].profe.datper.nombre:='';
curso.modulo[i].profe.datper.ci:='';
curso.modulo[i].profe.datper.tlf:='';
curso.modulo[i].profe.datper.dir:='';
curso.modulo[i].profe.datac.prof:='';
curso.modulo[i].profe.datac.aexp:=0;

end;
end;

procedure llenar(var curso:tipcurso);

begin

writeln('Ingrese Nombre del curso');
readln(curso.nomb);
writeln('ingrese el valor del curso');
readln(curso.costo);
writeln('Datos personales del Coordinador');
writeln('Ingrese nombre ');
readln(curso.coord.datper.nombre);
writeln('ingrese Cedula');
readln(curso.coord.datper.ci);
writeln('ingrese numero de telefono');
readln(curso.coord.datper.tlf);
writeln('ingrese direccion');
readln(curso.coord.datper.dir);
writeln('datos academicos del coordinador');
writeln('ingrese profesion');
readln(curso.coord.datac.prof);
writeln('ingrese anos de experiencia');
readln(curso.coord.datac.aexp);

for i:=1 to M do
begin

writeln('ingrese nombre del modulo #',i);
readln(curso.modulo[i].nombre);
writeln('ingrese la cantidad de horas del mudolo',i);
readln(curso.modulo[i].horas);
writeln('Datos del profesor del curso');
writeln('ingrese nombre del profesor del modulo',i);
readln(curso.modulo[i].profe.datper.nombre);
writeln('ingrese cedula del profesor del modulo',i);
readln(curso.modulo[i].profe.datper.ci);
writeln('ingrese numero de telefono del profe del modulo',i);
readln(curso.modulo[i].profe.datper.tlf);
writeln('ingrese direccion del profesor del modulo',i);
readln(curso.modulo[i].profe.datper.dir);
writeln('datos academicos de cada profesor');
writeln('ingrese profesion de profesor de modulo',i);
readln(curso.modulo[i].profe.datac.prof);
writeln('ingrese anos de experiencia');
readln(curso.modulo[i].profe.datac.aexp);


end;
end;

procedure mostrar(var curso:tipcurso);

begin

writeln('Nombre del Curso');
writeln(curso.nomb);
writeln('Costo del Curso');
writeln(curso.costo);
writeln('Datos del coordinador');
writeln('Nombre: ',curso.coord.datper.nombre);
writeln('Cedula: ',curso.coord.datper.ci);
writeln('Telefono: ',curso.coord.datper.tlf);
writeln('Direccion: ',curso.coord.datper.dir);
writeln('Datos academicos del coordinador');
writeln('Profesion: ',curso.coord.datac.prof);
writeln('Anos de experiencia: ',curso.coord.datac.aexp);

for i:=1 to M do
begin
writeln('Nombre de modulo ',i);
writeln(curso.modulo[i].nombre);
writeln('Horas del curso ',i);
writeln( curso.modulo[i].horas);
writeln('Datos personales del profesor',i);
writeln('Nombre del profesor: ',curso.modulo[i].profe.datper.nombre);
writeln('Cedula: ',curso.modulo[i].profe.datper.ci);
writeln('Telefono: ',curso.modulo[i].profe.datper.tlf);
writeln('Direccion: ',curso.modulo[i].profe.datper.dir);
writeln('Datos academicos del profesor ',i);
writeln('Profesion: ',curso.modulo[i].profe.datac.prof);
writeln('Anos de experiencia: ',curso.modulo[i].profe.datac.aexp);

end;
end;

procedure modificar(var curso:tipcurso);
var
modifi:char;
nuevo:string;
begin


writeln('Numero del coordinador es: ', curso.coord.datper.tlf);
curso.coord.datper.tlf:=nuevo;
readln(nuevo);
writeln('ingrese nuevo telefono');
writeln('nuevo telefono del coordinador: ', nuevo);

end;
begin
writeln('algorimo que lee cursos ');

limipar(curso);
llenar(curso);
mostrar(curso);
modificar(curso);
readln;
end.
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

necesito modificar es registro a un archivo

Publicado por ramon (2158 intervenciones) el 08/02/2015 01:03:11
Lo tienes en el anterior resuelto
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

necesito modificar es registro a un archivo

Publicado por manuel (4 intervenciones) el 08/02/2015 01:10:41
si pero como imcorporo esas opciones ramon porfa ayudame con eso
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

necesito modificar es registro a un archivo

Publicado por ramon (2158 intervenciones) el 08/02/2015 11:57:41
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
{Míralo}
 
 program procesacurso;
  uses
     crt;
 
  const
      M = 5;
  type
     tipdatper = record
          nombre, ci, tlf, dir : string;
          end;
 
     tipdatac = record
          prof : string;
          aexp : integer;
         end;
 
       tipmod = record
            nombre : string;
             horas : integer;
              profe:record
                 datper : tipdatper;
                  datac : tipdatac;
                end;
             end;
 
        tipcurso = record
             nomb : string;
            costo : real;
            coord : record
           datper : tipdatper;
            datac : tipdatac;
             end;
           modulo : array[1..M] of tipmod;
         end;
 
        arcurso = file of tipcurso;
 
    var
         c : arcurso;
     curso : tipcurso;
         i : integer;
       opc : char;
 
procedure limpiar(var curso:tipcurso);
begin
curso.costo:=0;
curso.nomb:='';
curso.coord.datper.nombre:='';
curso.coord.datper.ci:='';
curso.coord.datper.tlf:='';
curso.coord.datper.dir:='';
curso.coord.datac.prof:='';
curso.coord.datac.aexp:=0;
 
for i:=1 to M do
begin
curso.modulo[i].nombre:='';
curso.modulo[i].horas:=0;
curso.modulo[i].profe.datper.nombre:='';
curso.modulo[i].profe.datper.ci:='';
curso.modulo[i].profe.datper.tlf:='';
curso.modulo[i].profe.datper.dir:='';
curso.modulo[i].profe.datac.prof:='';
curso.modulo[i].profe.datac.aexp:=0;
end;
end;
 
 procedure llenar(var cur : tipcurso);
 var
  contador : string;
  begin
    i := 0;
    assign (c,'C:\tp\bin\curso.dat');
    rewrite(c);
    seek(c,i);
    writeln('Ingrese Nombre del curso');
    readln(curso.nomb);
    contador := curso.nomb;
    writeln('ingrese el valor del curso');
    readln(curso.costo);
    writeln('Datos personales del Coordinador');
    writeln('Ingrese nombre ');
    readln(curso.coord.datper.nombre);
    writeln('ingrese Cedula');
    readln(curso.coord.datper.ci);
    writeln('ingrese numero de telefono');
    readln(curso.coord.datper.tlf);
    writeln('ingrese direccion');
    readln(curso.coord.datper.dir);
    writeln('datos academicos del coordinador');
    writeln('ingrese profesion');
    readln(curso.coord.datac.prof);
    writeln('ingrese anos de experiencia');
    readln(curso.coord.datac.aexp);
    for i := 1 to M do
    begin
       writeln('ingrese nombre del modulo #',i);
       readln(curso.modulo[i].nombre);
       writeln('ingrese la cantidad de horas del mudolo',i);
       readln(curso.modulo[i].horas);
       writeln('Datos del profesor del curso');
       writeln('ingrese nombre del profesor del modulo',i);
       readln(curso.modulo[i].profe.datper.nombre);
       writeln('ingrese cedula del profesor del modulo',i);
       readln(curso.modulo[i].profe.datper.ci);
       writeln('ingrese numero de telefono del profe del modulo',i);
       readln(curso.modulo[i].profe.datper.tlf);
       writeln('ingrese direccion del profesor del modulo',i);
       readln(curso.modulo[i].profe.datper.dir);
       writeln('datos academicos de cada profesor');
       writeln('ingrese profesion de profesor de modulo',i);
       readln(curso.modulo[i].profe.datac.prof);
       writeln('ingrese anos de experiencia');
       readln(curso.modulo[i].profe.datac.aexp);
      end;
      write(c,curso);
      close(c);
    end;
 
   procedure mostrar(curso : tipcurso);
   begin
      assign (c,'C:\tp\bin\curso.dat');
  {$I-} reset(c); {$I+}
   if IOResult = 0 then
   begin
    seek(c,0);
    read(c,curso);
    clrscr;
    writeln('Nombre del Curso');
    writeln(curso.nomb);
    writeln('Costo del Curso');
    writeln(curso.costo);
    writeln('Datos del coordinador');
    writeln('Nombre: ',curso.coord.datper.nombre);
    writeln('Cedula: ',curso.coord.datper.ci);
    writeln('Telefono: ',curso.coord.datper.tlf);
    writeln('Direccion: ',curso.coord.datper.dir);
    writeln('Datos academicos del coordinador');
    writeln('Profesion: ',curso.coord.datac.prof);
    writeln('Anos de experiencia: ',curso.coord.datac.aexp);
    for i := 1 to M do
    begin
     writeln('Nombre de modulo ',i);
     writeln(curso.modulo[i].nombre);
     writeln('Horas del curso ',i);
     writeln( curso.modulo[i].horas);
     writeln('Datos personales del profesor',i);
     writeln('Nombre del profesor: ',curso.modulo[i].profe.datper.nombre);
     writeln('Cedula: ',curso.modulo[i].profe.datper.ci);
     writeln('Telefono: ',curso.modulo[i].profe.datper.tlf);
     writeln('Direccion: ',curso.modulo[i].profe.datper.dir);
     writeln('Datos academicos del profesor ',i);
     writeln('Profesion: ',curso.modulo[i].profe.datac.prof);
     writeln('Anos de experiencia: ',curso.modulo[i].profe.datac.aexp);
     end;
     close(c);
   end;
  end;
 
   procedure insertarcurso(var curso : tipcurso);
  begin
      assign (c,'C:\tp\bin\curso.dat');
   {$I-} reset(c); {$I+}
   if ioresult <> 0 then
   begin
      writeln('  Error de archivo o falta pulse una tecla');
      readkey;
   end
 else
    begin
       seek(c,filesize(c));
       writeln('Ingrese Nombre del curso');
    readln(curso.nomb);
    writeln('ingrese el valor del curso');
    readln(curso.costo);
    writeln('Datos personales del Coordinador');
    writeln('Ingrese nombre ');
    readln(curso.coord.datper.nombre);
    writeln('ingrese Cedula');
    readln(curso.coord.datper.ci);
    writeln('ingrese numero de telefono');
    readln(curso.coord.datper.tlf);
    writeln('ingrese direccion');
    readln(curso.coord.datper.dir);
    writeln('datos academicos del coordinador');
    writeln('ingrese profesion');
    readln(curso.coord.datac.prof);
    writeln('ingrese anos de experiencia');
    readln(curso.coord.datac.aexp);
    for i := 1 to M do
    begin
       writeln('ingrese nombre del modulo #',i);
       readln(curso.modulo[i].nombre);
       writeln('ingrese la cantidad de horas del mudolo',i);
       readln(curso.modulo[i].horas);
       writeln('Datos del profesor del curso');
       writeln('ingrese nombre del profesor del modulo',i);
       readln(curso.modulo[i].profe.datper.nombre);
       writeln('ingrese cedula del profesor del modulo',i);
       readln(curso.modulo[i].profe.datper.ci);
       writeln('ingrese numero de telefono del profe del modulo',i);
       readln(curso.modulo[i].profe.datper.tlf);
       writeln('ingrese direccion del profesor del modulo',i);
       readln(curso.modulo[i].profe.datper.dir);
       writeln('datos academicos de cada profesor');
       writeln('ingrese profesion de profesor de modulo',i);
       readln(curso.modulo[i].profe.datac.prof);
       writeln('ingrese anos de experiencia');
       readln(curso.modulo[i].profe.datac.aexp);
      end;
      write(c,curso);
      close(c);
    end;
  end;
 
  procedure buscar_curso;
  var
     g : integer;
     ncurso : string;
     cont : longint;
     siesta : boolean;
  begin
     siesta := false;
     writeln('  Buscar Curso Por Su Nombre ');
     writeln;
     write('  Nombre Curso : ');
     readln(ncurso);
     for g := 1 to length(ncurso) do
     ncurso[g] := upcase(ncurso[g]);
     assign (c,'C:\tp\bin\curso.dat');
   {$I-} reset(c); {$I+}
   if ioresult <> 0 then
   begin
      writeln('  Error de archivo o falta pulse una tecla');
      readkey;
   end
 else
    begin
       for cont := 0 to filesize(c) - 1 do
       begin
          seek(c,cont);
          read(c,curso);
          for g := 1 to length(curso.nomb) do
          curso.nomb[g] := upcase(curso.nomb[g]);
          if ncurso = curso.nomb then
          begin
             siesta := true;
             close(c);
             break;
          end;
       end;
    end;
       if siesta = false then
       begin
          writeln('  Curso No Encontrado Pulse Una Tecla');
          readkey;
       end
    else
       begin
         clrscr;
          writeln('Nombre del Curso');
    writeln(curso.nomb);
    writeln('Costo del Curso');
    writeln(curso.costo);
    writeln('Datos del coordinador');
    writeln('Nombre: ',curso.coord.datper.nombre);
    writeln('Cedula: ',curso.coord.datper.ci);
    writeln('Telefono: ',curso.coord.datper.tlf);
    writeln('Direccion: ',curso.coord.datper.dir);
    writeln('Datos academicos del coordinador');
    writeln('Profesion: ',curso.coord.datac.prof);
    writeln('Anos de experiencia: ',curso.coord.datac.aexp);
    for i := 1 to M do
    begin
     writeln('Nombre de modulo ',i);
     writeln(curso.modulo[i].nombre);
     writeln('Horas del curso ',i);
     writeln( curso.modulo[i].horas);
     writeln('Datos personales del profesor',i);
     writeln('Nombre del profesor: ',curso.modulo[i].profe.datper.nombre);
     writeln('Cedula: ',curso.modulo[i].profe.datper.ci);
     writeln('Telefono: ',curso.modulo[i].profe.datper.tlf);
     writeln('Direccion: ',curso.modulo[i].profe.datper.dir);
     writeln('Datos academicos del profesor ',i);
     writeln('Profesion: ',curso.modulo[i].profe.datac.prof);
     writeln('Anos de experiencia: ',curso.modulo[i].profe.datac.aexp);
     end;
    end;
  end;
 
  procedure mostrar_cuantos_cursos_coordina_un_profesor;
  var
    nombrecor : string;
    cont : longint;
    cordi, d : integer;
   begin
       clrscr;
       cordi := 0;
       writeln('   Entre Nombre Cordinador ');
       writeln;
       write('   Nombre : ');
       readln(nombrecor);
       for d := 1 to length(nombrecor) do
       nombrecor[d] := upcase(nombrecor[d]);
       assign (c,'C:\tp\bin\curso.dat');
   {$I-} reset(c); {$I+}
   if ioresult <> 0 then
   begin
      writeln('  Error de archivo o falta pulse una tecla');
      readkey;
   end
 else
    begin
       for cont := 0 to filesize(c) - 1 do
       begin
          seek(c,cont);
          read(c,curso);
          for d := 1 to length(curso.coord.datper.nombre) do
          curso.coord.datper.nombre[d] := upcase(curso.coord.datper.nombre[d]);
          if nombrecor = curso.coord.datper.nombre then
          begin
             cordi := cordi + 1;
          end;
       end;
         close(c);
         writeln;
         writeln('  El Cordinador Tiene A su Cargo Cursos : ',cordi);
         writeln;
         writeln('  Pulse Una Tecla');
         readkey;
    end;
   end;
 
   begin
      clrscr;
{Incorpora esto en un menú y ejecutaras lo que sea}
      limpiar(curso);
      llenar(curso);
      mostrar(curso);
      insertarcurso(curso);
      buscar_curso;
      mostrar_cuantos_cursos_coordina_un_profesor;
      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