Pascal/Turbo Pascal - Ejercicio fin de curso ayuda

 
Vista:
sin imagen de perfil

Ejercicio fin de curso ayuda

Publicado por Antonio (7 intervenciones) el 11/05/2015 16:16:34
1
2
3
4
5
6
7
8
9
TYPE
 
        REG1=RECORD
            	 Autor:STRING[20];
           	 Edito:STRING[30];
            	 Cod_Libro:longint;
             	 Lugar:string[30];
             	 con:char;
        END;

Crear un Fichero tipo (REG1).

Al entrar seleccionar uno de los siguientes Archivos :

Revistas
Libros
CD
Libros_Text
Docvarios

Una vez seleccionado el Archivo y Creado acceder al Menu de Gestión del
Archivo con estas Opciones :

(1) ENTRADA
(2) LISTADO
(3) BUSQUEDA
(4) REORGA
(5) MODIFICA
(6) SEL_FICHERO
(7) SALIR


Entrada : Entraremos los datos controlados en el Registro ,el campo con se le asignará
de forma automática una (a),Cod_libro será campo único y lo guardamos en el Archivo.

Búsqueda : nos pedirá la Editorial ,si existe ,visualiza de forma oindividual cada Registro
de la Editorial ,pudiendo cambiar el campo con de (a) a (b) o de (b) a (a).


Reorga : En esta opción dejaremos el Archivo selecionado unicamente con los
valores que en el campo con valgán (a).

Modifica : Nos Pédira el Cod_Libro si existe nos permitirá modificar
los campos Autor ,Editorial y Lugar del Libro con ese Còdigo.
Se podrá modificar un campo,dos o tres.

Sel_FiChero :Opción donde selecciono el Archivo a usar:

Revistas
Libros
CD
Libros_Text
Docvarios

Dudas consultar.

Realizar Primero la Entrada y Listado.

Si es posible usar sólo variables locales .

#######

Si alguien pudiera dejarmelo explicado cada paso del ejercicio terminado se lo agradeceria. Porque no soy capaz de hacerlo. Muchas gracias. Dare voto positivo
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
sin imagen de perfil

Ejercicio fin de curso ayuda

Publicado por Antonio (7 intervenciones) el 13/05/2015 18:03:17
Nadie puede ayudarme?
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

Ejercicio fin de curso ayuda

Publicado por ramon (2158 intervenciones) el 13/05/2015 21:12:12
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
347
348
349
350
351
352
353
354
355
356
357
{Espero esto te ayude}
 
 program registros;
  uses
     crt;
 
   type
 
     REG1 = record
           Autor : string[20];
           Edito : string[30];
       Cod_Libro : longint;
           Lugar : string[30];
             con : char;
        end;
 
 
  var
    dato : array[1..50] of reg1;
    f : file of reg1;
    cont : longint;
 
 
   procedure guardar_dato(g : reg1);
   begin
       assign(f,'Libros.dat');
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       rewrite(f);
       seek(f,0);
       write(f,g);
       close(f);
    end
  else
     begin
        seek(f,filesize(f));
        write(f,g);
        close(f);
     end;
  end;
 
 
  procedure carga_dato;
  var
     carg : longint;
     toma : integer;
  begin
      assign(f,'Libros.dat');
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('   Error De Archivo Pulse Una Tecla');
       readkey;
    end
  else
      begin
         if filesize(f) - 1 > 50 then
         begin
         toma := 50;
         cont := toma;
         end
       else
         begin
         toma := filesize(f) - 1;
         cont := toma + 1;
         end;
         writeln('  Inicio Carga Datos');
         delay(200);
         for carg := 0 to toma do
         begin
             seek(f,carg);
             read(f,dato[carg + 1]);
         end;
           close(f);
           writeln('  Carga Finalizada');
           delay(400);
           clrscr;
      end;
    end;
 
 
  procedure entrada_datos;
  var
    te : char;
  begin
     clrscr;
     writeln('   ***** Entrada De Datos *****');
     writeln;
     write('   Entre Autor     : ');
     readln(dato[1].autor);
     write('   Entre Edito     : ');
     readln(dato[1].edito);
     write('   Entre Cod_Libro : ');
     readln(dato[1].Cod_Libro);
     write('   Entre Lugar     : ');
     readln(dato[1].Lugar);
     dato[1].con := 'a';
     writeln;
     writeln('  Los Datos Son correctos [S/N]');
     repeat
         te := upcase(readkey);
     until te in['S','N'];
     if te = 'S' then
     begin
        guardar_dato(dato[1]);
     end
   else
      begin
         te := chr(0);
         writeln;
         writeln('  Desea Entrar Los Datos De Nuevo [S/N]');
         repeat
         te := upcase(readkey);
         until te in['S','N'];
         if te = 'S' then
         entrada_datos;
      end;
  end;
 
  procedure presenta_dato;
  var
    i : longint;
  begin
     carga_dato;
     gotoxy(4,1);write(' Autor        Editor     Codogo    Lugar        con');
     for i := 1 to cont do
     begin
        gotoxy(5,2 + i);write(dato[i].autor);
        gotoxy(18,2 + i);write(dato[i].edito);
        gotoxy(29,2 + i);write(dato[i].Cod_Libro);
        gotoxy(39,2 + i);write(dato[i].Lugar);
        gotoxy(52,2 + i);write(dato[i].con);
     end;
     gotoxy(19,4 + i);write('   Pulse Una Tecla');
     readkey;
  end;
 
  procedure busqueda_dato;
  var
     paso, ed : string[30];
     pp, tt, yy : integer;
     temp : array[1..50] of reg1;
  begin
     clrscr;
     writeln('    ***** Busqueda Editorial *****');
     writeln;
     write('   Entre Editorial : ');
     readln(ed);
     for yy := 1 to length(ed) do
     begin
     ed[yy] := upcase(ed[yy]);
     ed[0] := chr(yy);
     end;
     carga_dato;
     tt := 0;
     for yy := 1 to cont do
     begin
       for pp := 1 to length(dato[yy].Edito) do
       begin
       paso[pp] := upcase(dato[yy].Edito[pp]);
       paso[0] := chr(pp);
       end;
     if paso = ed then
     begin
     tt := tt + 1;
     temp[tt] := dato[yy];
     end;
    end;
     clrscr;
     gotoxy(4,1);write(' Autor        Editor     Codogo    Lugar        con');
     for pp := 1 to tt do
     begin
        gotoxy(5,2 + pp);write(dato[pp].autor);
        gotoxy(18,2 + pp);write(dato[pp].edito);
        gotoxy(29,2 + pp);write(dato[pp].Cod_Libro);
        gotoxy(39,2 + pp);write(dato[pp].Lugar);
        gotoxy(52,2 + pp);write(dato[pp].con);
     end;
       readkey;
  end;
 
  procedure reorganiza_dato;
  var
    tp : file of reg1;
    z, ll : longint;
    begin
     assign(f,'Libros.dat');
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('   Error De Archivo Pulse Una Tecla');
       readkey;
    end
  else
      begin
         z := 0;
         assign(tp,'Temporal.tmp');
         rewrite(tp);
         for ll := 0 to filesize(f) - 1 do
         begin
         seek(f,ll);
         read(f,dato[1]);
         if dato[1].con = 'a' then
         begin
            seek(tp,z);
            write(tp, dato[1]);
            z := z + 1;
         end;
      end;
        close(tp);
        close(f);
        erase(f);
        rename(tp,'Libros.dat');
        writeln('  Organizacion Realizada Pulse Una Tecla');
        readkey;
     end;
   end;
 
   procedure modificar_datos;
   var
      tew : char;
      col, bu, cd : longint;
      fin, encot : boolean;
   begin
       clrscr;
       writeln('    Modificar Datos');
       writeln;
       write('   Entre Codigo Libro : ');
       readln(cd);
       assign(f,'Libros.dat');
    {$I-} reset(f); {$I+}
    if ioresult <> 0 then
    begin
       writeln('   Error De Archivo Pulse Una Tecla');
       readkey;
    end
  else
      begin
         encot := false;
         for bu := 0 to filesize(f) - 1 do
         begin
            seek(f,bu);
            read(f,dato[1]);
            if dato[1].Cod_Libro = cd then
            begin
               encot := true;
               col := bu;
               break;
            end;
         end;
      if encot = true then
      begin
       fin := false;
       clrscr;
       gotoxy(4,1);write(' Autor        Editor     Codogo    Lugar        con');
       gotoxy(5,2 + 1);write(dato[1].autor);
       gotoxy(18,2 + 1);write(dato[1].edito);
       gotoxy(29,2 + 1);write(dato[1].Cod_Libro);
       gotoxy(39,2 + 1);write(dato[1].Lugar);
       gotoxy(52,2 + 1);write(dato[1].con);
     repeat
       gotoxy(18,5);write('  Opcion Modificar');
       gotoxy(18,7);write('  A = Autor');
       gotoxy(18,8);write('  E = Editor');
       gotoxy(18,9);write('  C = Codogo');
       gotoxy(18,10);write('  L = Lugar');
       gotoxy(18,11);write('  N = Con');
       gotoxy(18,12);write('  S = Finalizar');
       repeat
           tew := upcase(readkey);
       until tew in['A','E','C','L','N','S'];
       gotoxy(18,14);clreol;
     case tew of
  'A' : begin gotoxy(18,14);write('  Autor : ');readln(dato[1].autor);
              gotoxy(5,2 + 1);write(dato[1].autor); end;
  'E' : begin gotoxy(18,14);write('  Editor : ');readln(dato[1].Edito);
              gotoxy(18,2 + 1);write(dato[1].edito); end;
  'C' : begin gotoxy(18,14);write('  Codigo : ');readln(dato[1].Cod_Libro);
              gotoxy(29,2 + 1);write(dato[1].Cod_Libro); end;
  'L' : begin gotoxy(18,14);write('  Lugar : ');readln(dato[1].Lugar);
              gotoxy(39,2 + 1);write(dato[1].Lugar); end;
  'N' : begin gotoxy(18,14);write('  Con : ');readln(dato[1].con);
              gotoxy(52,2 + 1);write(dato[1].con); end;
  'S' : fin := true;
    end;
    until fin = true;
    seek(f,col);
    write(f,dato[1]);
    close(f);
    end
  else
     begin
        clrscr;
        writeln('   Codigo No Encontrado Pulse Una Tecla');
        readkey;
        close(f);
     end;
    end;
   end;
 
 
 
 
  procedure menuinicio;
  var
    salir : boolean;
    tecla : char;
  begin
     salir := false;
     cont := 0;
   repeat
       clrscr;
       writeln('    ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿');
       writeln('    ³   *** Menu Inicio ***  ³');
       writeln('    ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´');
       writeln('    ³  1 = ENTRADA           ³');
       writeln('    ³  2 = LISTADO           ³');
       writeln('    ³  3 = BUSQUEDA          ³');
       writeln('    ³  4 = REORGA            ³');
       writeln('    ³  5 = MODIFICA          ³');
       writeln('    ³  6 = SEL_FICHERO       ³');
       writeln('    ³  7 = SALIR             ³');
       writeln('    ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
       writeln;
       writeln('    ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿');
       writeln('    ³  <<< Elija Opcion >>>  ³');
       writeln('    ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
       repeat
           tecla := readkey;
       until tecla in['1','2','3','4','5','6','7'];
       clrscr;
      case tecla of
  '1' : entrada_datos;
  '2' : presenta_dato;
  '3' : busqueda_dato;
  '4' : reorganiza_dato;
  '5' : modificar_datos;
  '6' : begin
       clrscr;
       writeln('   Todos los datos se encuentran en un solo archivo');
       writeln('   el programa es el encargado de presentarte el tipo');
       writeln('   de archivo que tu le pidas pero solo existe un archivo');
       writeln('   si quieres tendras que marcar el tipo de dato que se');
       writeln('   a guardado en ese registro.');
       writeln('   Por Ejemplo: tipo : char; y seria = ');
       writeln('   [R] = Revistas, [L] = Libros, [C] = CD, [T] = Libros_Text');
       writeln('   [D] = Docvarios');
        end;
  '7' : salir := true;
    end;
   until salir = true;
  end;
 
  begin
     menuinicio;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
2
Comentar
sin imagen de perfil

Ejercicio fin de curso ayuda

Publicado por Antonio (7 intervenciones) el 13/05/2015 22:41:43
Muchas gracias ramon, esta tarde he aprovexado a empezarlo a mi manera y de momento he conseguido todo excepto el apartado busqueda. Ahora que veo tu resultado aprovexare a implementarlo. Si tengo algun problema no dudare en preguntartelo. Gracias.
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

Ejercicio fin de curso ayuda

Publicado por Antonio (7 intervenciones) el 13/05/2015 22:48:11
Me he tenido que registrar para darte voto positivo.
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