Pascal/Turbo Pascal - Problemas con archivos de registro.

 
Vista:
sin imagen de perfil

Problemas con archivos de registro.

Publicado por Martino (4 intervenciones) el 25/10/2014 04:13:15
Buenas , tengo una serie de problemas y queria ver si son tan amables de ayudarme, no me puedo dar cuenta que es lo que estoy haciendo mal. El programa funciona (mas o menos) pero tengo los siguientes problemas, cuando quiero agregar 1 usuario o un 1 instrumento, me doy cuenta que el archivo no se expande, puse un write filesize para ver el tamaño. y por ejemplo, si yo tengo 4 usuarios registrados, al agregar el 5to siempre me queda en 4 , y no se si es que me borra el primero o me borra el ultimo.Adema,después de agregar el usuario o instrumento cierro el programa y lo vuelvo a abrir y puedo realizar operaciones con el mismo, pero si lo cierro y abro de nuevo ya me aparece como que no existe. Tal vez hay algo que yo este haciendo mal, algun recorrido de archivo, o no se.
NOTA : al principio inicializo las variables de numero_user y numero_inst en 0 y se la voy agregando a los clientes/instrumentos pero al reiniciar el programa me quedarian 2 usuarios con el mismo codigo esos son detalles que despues pienso corregir.


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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
program projecto;
USES crt;
CONST {declaracion de archivos como constantes}
FICHEROPER =  'D:\Programacion\PASCAL\Ficheros\ficherouser1.dat'; {fichero guarda clientes 1}
FICHEROPERT = 'D:\Programacion\PASCAL\Ficheros\ficherouser2.dat'; {Fichero aux}
FICHEROINS =  'D:\Programacion\PASCAL\Ficheros\ficheroinst1.dat'; {fichero guarda instrumentos 1}
FICHEROINST = 'D:\Programacion\PASCAL\Ficheros\Ficheroinst2.dat'; {fichero aux cli}
TYPE
 
regcli = record              {Registro de clientes}
 nomape: string[255];
 documento,telefono: real;
 nrouser: word;
 direccion: string[255];
 prestamo: boolean;
end;
 
reginst = record              {Registro de Instrumentos}
 Nombre,Tipo: string[20];
 stock: word;
 codigo: word;
end;
clientes=file of regcli;
instrumentos=file of reginst;
 
 
procedure cargacli (var clients:clientes ; var reg_cli:regcli ; var num_user:word); {procedimiento carga de datos de cliente}
begin
writeln ('ingrese el numero de documento sin (.)');
readln (reg_cli.documento);
writeln ('ingrese el numero de telefono');
readln (reg_cli.telefono);
writeln ('ingrese la direccion');
readln (reg_cli.direccion);
reg_cli.prestamo := false;
reg_cli.nrouser := num_user + 1;
num_user:=reg_cli.nrouser;
writeln ('El codigo de usuario es ', reg_cli.nrouser);
end;
 
procedure cargains (var instru:instrumentos; var reg_ins:reginst; var num_inst:word); {procedimiento carga de instrumentos}
begin
writeln ('ingrese el tipo de instrumento [CUERDA / VIENTO / ELECTRONICO / PERCUCION]');
readln (reg_ins.Tipo);
writeln ('ingrese la cantidad de instrumentos a registrar');
readln (reg_ins.stock);
reg_ins.codigo:=num_inst + 1;
num_inst:= reg_ins.codigo;
writeln ('el codigo del instrumento es ', reg_ins.codigo);
end;
 
procedure clisearch (var clients:clientes ; var reg_cli:regcli; var controlc:real ;var exist:boolean;var a:word );  {procedimiento recorrer archivo buscando clientes}
var
i:word;
begin
exist:=false;
i:=0;
writeln ('Ingrese su DNI sin puntos [.]');
readln (controlc);
for i:=0 to fileSize(clients)-1 do
begin
seek (clients,i);
read (clients,reg_cli);
if reg_cli.documento=controlc then
begin
a:=i;
exist:=true;
writeln ('El nombre y apellido es :',reg_cli.nomape);
writeln ('El numero de documento es:',reg_cli.documento:8:0);
writeln ('El numero de telefono es:',reg_cli.telefono:12:0);
writeln ('La direccion es:',reg_cli.direccion);
writeln ('El numero de usuario es:',reg_cli.nrouser);
 if reg_cli.prestamo = true then
               begin
               writeln ('El usuario posee instrumentos prestados');
               end
               else
               writeln ('El usuario no posee instrumentos prestados');
end;
end;
if exist=false then
begin
 writeln ('No existe un usuario con el documento nro >> ', controlc:8:0 ,' <<');
end;
end;
 
procedure editcli (var clients:clientes ; var reg_cli:regcli);    {Procedimiento editar usuario}
var
k:word;
begin
writeln ('1) Para editar nombre y apellido');
writeln ('2) Para editar DNI');
writeln ('3) Para editar numero telefonico');
writeln ('4) Para editar domicilio');
readln (k);
case k of
 1: begin
     writeln ('Ingrese el nuevo nombre');
     readln (reg_cli.nomape)
    end;
 2: begin
     writeln ('Ingrese el nuevo DNI');
     readln (reg_cli.documento);
    end;
 3: begin
     writeln ('Ingrese el nuevo numero telefonico');
     readln (reg_cli.telefono);
 end;
 4: begin
     writeln ('Ingrese el nuevo domicilio');
     readln (reg_cli.direccion);
 end;
 end;
 writeln ('*DATOS MODIFICADOS CON EXITO*');
end;
 
procedure borraruser (var a:word ; var clients:clientes ; var clientsx:clientes);   {procedimiento borrar usuario}
var
l,m:word;
reg_cliaux: regcli;
reg_cliaux2: regcli;
begin
  Assign (clientsx,FICHEROPERT);
  rewrite (clientsx);
  for l:= 0 to filesize(clients)-1 do
   begin
   if l <> a then
    begin
    seek (clients,l);
    read (clients,reg_cliaux);
    reg_cliaux2:=reg_cliaux;
    write (clientsx,reg_cliaux2);
    end;
   end;
   ReWrite (clients);
   for m:=0 to filesize(clientsx)-1 do
    begin
    seek (clientsx,m);
    read (clientsx,reg_cliaux2);
    reg_cliaux:=reg_cliaux2;
    write (clients,reg_cliaux);
    end;
   close (clientsx);
end;
 
procedure borrarinst (var a:word ; var instru:instrumentos ; var instrux:instrumentos); {procedimiento borrar instrumento}
var
l,m:word;
reg_insaux:reginst;
reg_insaux2:reginst;
begin
Assign (instrux,FICHEROINST);
rewrite (instrux);
for l:=0 to filesize(instru)-1 do
 begin
 if l <> a then
  begin
  seek (instru,l);
  read (instru,reg_insaux);
  reg_insaux2:=reg_insaux;
  write (instrux,reg_insaux2);
  end;
  end;
  Rewrite (instru);
  for m:=0 to filesize(instrux)-1 do
   begin
   seek (instrux,m);
   read (instrux,reg_insaux2);
   reg_insaux:=reg_insaux2;
   write (instru,reg_insaux);
   end;
  close (instrux);
 end;
 
 
VAR
m,rta3,a,aux,rta,i,prueba,cant_regcli,cant_regins,menu,num_user,num_inst,search,cantreg_ins:word;
clients,clientsx: clientes;
instru,instrux: instrumentos;
reg_cli: regcli;
reg_ins: reginst;
controlA,controlB:string[20];
exist:boolean;
controlc:real;
rta2,rta4:char;
 
 
BEGIN
clrscr;
writeln ('Ingrese la opcion que desea (1-2-3-4)');
writeln ('1)Agregar un usuario');
writeln ('2)Agregar un instrumento');
writeln ('3)Buscar un usuario o instrumento');
readln (menu);
num_user:=0;
num_inst:=0;
Assign (clients,FICHEROPER);
Reset (clients); {poner el while aca abajo}
 
 
case menu of
 
1:Begin    {caso principal agregar usuario}
  Writeln ('  ***** Selecciono agregar un usuario *****  ');
  writeln;
  writeln (FileSize(clients)); {BORRAR DESPUES}
 
    readkey;
   Writeln ('Ingrese el nombre y apellido de la persona a inscribir');
   readln ( reg_cli.nomape);
    while reg_cli.nomape <> '_FIN' do
     Begin
     cargacli (clients,reg_cli,num_user);
     write (clients,reg_cli);
     writeln ('Si desea inscribir otra persona ingrese su nombre y apellido, sino "_FIN" para terminar');
     readln (reg_cli.nomape);
    end;
 
  end;
 
2:begin     {caso principal agregar instrumento}
  Writeln ('  ***** Selecciono agregar un instrumento *****  ');
  writeln;
  Assign (instru,FICHEROINS);
  ReSet (instru);
  prueba:=filesize (instru);
  writeln (prueba);
  readkey;
  Writeln ('Presione 1 para agregar un nuevo instrumento o 2 para agregar stock a uno ya existente');
  readln (rta);
  case rta of
    1:begin
    writeln ('Ingrese el nombre del instrumento');
    readln (reg_ins.Nombre);
    while reg_ins.nombre <> '_FIN' do
    begin
    cargains (instru,reg_ins,num_inst);
    write (instru,reg_ins);
    writeln ('Si desesa agregar otro instrumento ingrese su nombre o sino "_FIN" para terminar');
    readln (reg_ins.Nombre);
    end;
    end;
    2:begin
    writeln ('Ingrese el nombre del instrumento');
    readln (controlA);
    writeln ('Ingrese el tipo de instrumento');
    readln (controlB);
    for i:=0 to fileSize(instru)-1 do
     begin
      seek (instru,i);
      read (instru,reg_ins);
       if reg_ins.nombre=controlA then
       begin
        if reg_ins.tipo=controlB then
        begin
        Writeln ('Ingrese la cantidad de instrumentos (stock) a agregar');
        readln (aux);
        reg_ins.stock:=reg_ins.stock + aux;
        write (instru,reg_ins);
        writeln ('el stock actual es', reg_ins.stock);
    end else
       writeln ('No existe ningun instrumento con esas caracteristicas');
        end;
     end;
    close(instru);
   end;
  end;
  end;
 
3:begin           {caso principal buscador}
writeln ('  ***** Selecciono buscador *****  ');
writeln;
writeln ('Presione 1 para abrir buscador de usuarios');
writeln ('Presione 2 para abrir buscador de instrumentos');
readln (rta);
case rta of
 1:Begin
 Writeln ('  **** Se selecciono buscador de usuarios ****  ');
     clisearch (clients,reg_cli,controlc,exist,a);
     if exist = true then
      begin
      writeln ('El usuario fue encontrado');
      seek (clients,a);
      writeln ('Desea realizar una accion? S/N');
      readln (rta2);
      while rta2='s' do
       begin
          writeln ('Elija una de las opciones:');
          writeln ('1)Editar datos del usuario // 2)Eliminar Usuario');
          readln (rta3);
           case rta3 of
 
            1:begin
              editcli (clients,reg_cli);
              write (clients,reg_cli);
              end;
            2:begin
              writeln (' ¡¡Atencios todos los datos del usuario seleccionado seran eliminados!! ¿Continuar? S/N');
              readln  (rta4);
              if rta4 = 's' then
              begin
              borraruser (a,clients,clientsx);
              end;
              end;
              end;
            writeln ('Desea realizar otra accion? S/N');
            readln (rta2);
       end;
     end;
   end;
   2:Begin
    Assign (instru,FICHEROINS);
     Reset (instru);
     exist:=false;
     writeln ('  **** Se selecciono buscador de instrumentos ****  ');
     writeln ('Ingrese el nombre del instrumento');
     readln (controlA);
     writeln ('Ingrese el tipo de instrumento');
     readln (controlB);
     for i:=0 to fileSize(instru)-1 do
     begin
      seek (instru,i);
      read (instru,reg_ins);
       if reg_ins.nombre=controlA then
       begin
        if reg_ins.tipo=controlB then
        begin
         a:=i;
         exist:=true;
         writeln ('Instrumento encontrado');
       end else
       writeln ('No existe ningun instrumento con esas caracteristicas');
   end;
  end;
     if exist = true then
     begin
     writeln ('Los datos del instrumento seleccionado son:');
     writeln (reg_ins.Nombre);
     writeln (reg_ins.Tipo);
     writeln (reg_ins.stock);
     writeln ('Desea realizar alguna accion? S/N');
     readln (rta2);
     while rta2 = 's' do
      begin
      seek (instru,a);
      read (instru,reg_ins);
       writeln ('1)Editar datos del instrumento // 2)Borar instrumento ');
       readln (rta3);
       case rta3 of
        1:begin
           writeln ('1)Editar nombre del instrumento');
           writeln ('2)Editar el tipo de instrumento');
           writeln ('3)Modificar el stock del instrumento');
           readln  (m);
           case m of
            1:begin
               writeln ('Ingrese el nuevo nombre');
               readln (reg_ins.nombre);
               end;
            2:begin
               writeln ('Ingrese el nuevo tipo [VIENTO/CUERDA/PERCUCION/ELECTRICO]');
               readln (reg_ins.Tipo);
               end;
            3:begin
               writeln ('Ingrese el nuevo stock');
               writeln ('NOTA: el stock NO sera agregado a la cantidad actual, es decir, lo que usted ingrese ahora sera el stock total');
               readln (reg_ins.stock);
               end;
            end;
           write (instru,reg_ins);
           end;
        2:begin
            borrarinst (a,instru,instrux);
          end;
        end;
       writeln ('Desea realizar otra accion? S/N');
       readln (rta2);
      end;
     end;
    end;
  end;
 end;
end;{fincaso}
close (clients);
 
 
 
 
readkey;
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

Problemas con archivos de registro.

Publicado por ramon (2158 intervenciones) el 26/10/2014 21:17: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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
{Espero este ejemplo te hayude}
 
program cliente;
  uses
     crt;
  const
      archi_nombre = 'ficherouser1.dat';
      archi_istrum = 'ficheroinst1.dat';
 
  TYPE
    regcli = record {Registro de clientes}
         nomape : string;
     documento,telefono : real;
       nrouser : word;
      direccion: string;
      prestamo : boolean;
     end;
 
     reginst = record {Registro de Instrumentos}
       Nombre, Tipo : string[20];
              stock : word;
             codigo : word;
        end;
 
    var
      clientes : file of regcli;
      instrumentos : file of reginst;
      losdatoscli : regcli;
      loddatosinst : reginst;
      num_inst, num_user : word;
 
   procedure guarda_datos(cual : char);
   begin
      if cual = 'C' then    {Si es cliente guardamos aqui}
      begin
         assign(clientes,archi_nombre);
     {$I-} reset(clientes); {$I+}
         if ioresult <> 0 then
         begin                    {Si el archivo no existe lo creamos}
            rewrite(clientes);
            seek(clientes,0);
            write(clientes,losdatoscli);
            close(clientes);
         end
     else
         begin
            seek(clientes,filesize(clientes));    {Si existe A¤adimos}
            write(clientes,losdatoscli);
            close(clientes);
         end;
      end;
       if cual = 'I' then     {Si es Instrumento Guardamos aqui}
       begin
          assign(instrumentos,archi_istrum);
     {$I-} reset(instrumentos); {$I+}
         if ioresult <> 0 then
         begin
            rewrite(instrumentos);  {Si no existe lo creamos}
            seek(instrumentos,0);
            write(instrumentos,loddatosinst);
            close(instrumentos);
         end
     else
         begin
            seek(instrumentos,filesize(instrumentos));  {Si existe a¤adimos}
            write(instrumentos,loddatosinst);
            close(instrumentos);
         end;
       end;
   end;
 
   procedure entre_datos(cual : char);
   begin
      if cual = 'C' then  {Si es cliente Entramos sus datos y guardamos}
      begin
         writeln('  Entrada Datos Cliente ');
         writeln;
         write('ingrese el numero de documento sin (.) ');
         readln(losdatoscli.documento);
         write('ingrese el numero de telefono ');
         readln(losdatoscli.telefono);
         write('ingrese la direccion ');
         readln(losdatoscli.direccion);
         losdatoscli.prestamo := false;
         losdatoscli.nrouser := num_user + 1;
         num_user := losdatoscli.nrouser;
         writeln('El codigo de usuario es ', losdatoscli.nrouser);
         guarda_datos(cual);
         num_user := num_user + 1;
      end;
      if cual = 'I' then {Si es instrumentos entramos sus datos y guardamos}
      begin
          writeln('  Entrada Datos Instrumento ');
          writeln;
          writeln('ingrese el tipo de instrumento [CUERDA / VIENTO / ELECTRONICO / PERCUCION] ');
          readln(loddatosinst.Tipo);
          write('ingrese la cantidad de instrumentos a registrar ');
          readln(loddatosinst.stock);
          loddatosinst.codigo := num_inst + 1;
          num_inst := loddatosinst.codigo;
          writeln('el codigo del instrumento es ', loddatosinst.codigo);
          guarda_datos(cual);
          num_inst := num_inst + 1;
      end;
   end;
 
   procedure presenta_cliente(cual : char; cc : regcli; ii : reginst);
   begin
      if cual = 'C' then
      begin
      if cc.nrouser > 0 then
      begin
      with cc do
      begin
        write(nomape,'   ',documento:0:0,'   ',telefono:0:0,'   ',nrouser,'   ',
              direccion,'   ',prestamo);
      end;
    end;
  end;
    if cual = 'I' then
    begin
       if ii.codigo > 0 then
       begin
       with ii do
       begin
          write(Nombre,'   ',Tipo,'   ',stock,'   ',codigo);
       end;
     end;
    end;
      writeln;
   end;
 
   procedure presenta_archivo(cual : char);
   var
     arch : longint;
     con : integer;
   begin
      if cual = 'C' then
      begin
         assign(clientes,archi_nombre);
     {$I-} reset(clientes); {$I+}
         if ioresult <> 0 then
         begin
            writeln('   Error De Archivo O No Existe Pulse Una Tecla');
            readkey;
         end
     else
         begin
             con := 1;
           for arch := 0 to filesize(clientes) - 1 do
           begin
              seek(clientes,arch);
              read(clientes,losdatoscli);
              presenta_cliente('C',losdatoscli,loddatosinst);
              con := con + 1;
              if con > 4 then
              begin
                 writeln;
                 writeln('   Pulse Una Tecla');
                 readkey;
                 con := 1;
                 clrscr;
              end;
           end;
             writeln;
             writeln('   Pulse Una Tecla');
             readkey;
             close(clientes);
         end;
      end;
       if cual = 'I' then
       begin
          assign(instrumentos,archi_istrum);
     {$I-} reset(instrumentos); {$I+}
         if ioresult <> 0 then
         begin
            writeln('   Error De Archivo O No Existe Pulse Una Tecla');
            readkey;
         end
     else
         begin
             con := 1;
           for arch := 0 to filesize(instrumentos) - 1 do
           begin
              seek(instrumentos,arch);
              read(instrumentos,loddatosinst);
              presenta_cliente('I',losdatoscli,loddatosinst);
              con := con + 1;
              if con > 4 then
              begin
                 writeln;
                 writeln('   Pulse Una Tecla');
                 readkey;
                 con := 1;
                 clrscr;
              end;
           end;
             writeln;
             writeln('   Pulse Una Tecla');
             readkey;
             close(instrumentos);
         end;
       end;
   end;
 
   procedure muestra_un_cliente_o_instrumento(cual : char);
   var
      elc : word;
      arch : longint;
   begin
      if cual = 'C' then
      begin
         write('  Entre N. Usuario : ');
         readln(elc);
        assign(clientes,archi_nombre);
     {$I-} reset(clientes); {$I+}
         if ioresult <> 0 then
         begin
            writeln('   Error De Archivo O No Existe Pulse Una Tecla');
            readkey;
         end
     else
         begin
           for arch := 0 to filesize(clientes) - 1 do
           begin
              seek(clientes,arch);
              read(clientes,losdatoscli);
              if losdatoscli.nrouser = elc then
              begin
                  writeln('   Los Datos Del Cliente Son ');
                  writeln;
                  presenta_cliente('C',losdatoscli,loddatosinst);
                  writeln;
                  writeln('   Pulse Una Tecla');
                  readkey;
                  close(clientes);
                  break;
              end
           else
               begin
                  writeln('   El Cliente Entrado No Existe Pulse Una Tecla');
                  readkey;
                  close(clientes);
               end;
           end;
      end;
    end;
      if cual = 'I' then
      begin
         write('  Entre N. Codigo : ');
         readln(elc);
         assign(instrumentos,archi_istrum);
     {$I-} reset(instrumentos); {$I+}
         if ioresult <> 0 then
         begin
            writeln('   Error De Archivo O No Existe Pulse Una Tecla');
            readkey;
         end
     else
         begin
           for arch := 0 to filesize(instrumentos) - 1 do
           begin
              seek(instrumentos,arch);
              read(instrumentos,loddatosinst);
              if loddatosinst.codigo = elc then
              begin
              writeln('   Los Datos Del Instrumento Son ');
              writeln;
              presenta_cliente('I',losdatoscli,loddatosinst);
              writeln;
              writeln('   Pulse Una Tecla');
              readkey;
              close(instrumentos);
              break;
             end
       else
               begin
                  writeln('   El Codigo Entrado No Existe Pulse Una Tecla');
                  readkey;
                  close(instrumentos);
               end;
           end;
      end;
    end;
   end;
 
   procedure anular_cliente_o_instrumento(cual : char);
   var
      codi : word;
      arch : longint;
      tt : char;
   begin
      if cual = 'C' then
      begin
         write('  Entre N. Usuario a Anular : ');
         readln(codi);
        assign(clientes,archi_nombre);
     {$I-} reset(clientes); {$I+}
         if ioresult <> 0 then
         begin
            writeln('   Error De Archivo O No Existe Pulse Una Tecla');
            readkey;
         end
     else
         begin
           for arch := 0 to filesize(clientes) - 1 do
           begin
              seek(clientes,arch);
              read(clientes,losdatoscli);
              if losdatoscli.nrouser = codi then
              begin
                  clrscr;
                  writeln('   Esta Seguro Que Quiere Anular Los Datos De ');
                  writeln(losdatoscli.nrouser,'   S/N');
                  repeat
                     tt := upcase(readkey);
                  until tt in['S','N'];
                  if tt = 'S' then
                  begin
                     losdatoscli.nrouser := 0;
                     seek(clientes,arch);
                     write(clientes,losdatoscli);
                     close(clientes);
                     break;
                  end
               else
                  begin
                    close(clientes);
                    break;
                  end;
              end;
           end;
         end;
       end;
      if cual = 'I' then
      begin
         write('  Entre N. Codigo a Anular : ');
         readln(codi);
         assign(instrumentos,archi_istrum);
     {$I-} reset(instrumentos); {$I+}
         if ioresult <> 0 then
         begin
            writeln('   Error De Archivo O No Existe Pulse Una Tecla');
            readkey;
         end
     else
         begin
           for arch := 0 to filesize(instrumentos) - 1 do
           begin
              seek(instrumentos,arch);
              read(instrumentos,loddatosinst);
              if loddatosinst.codigo = codi then
              begin
                  clrscr;
                  writeln('   Esta Seguro Que Quiere Anular Los Datos De ');
                  writeln(loddatosinst.codigo,'   S/N');
                  repeat
                     tt := upcase(readkey);
                  until tt in['S','N'];
                  if tt = 'S' then
                  begin
                     loddatosinst.codigo := 0;
                     seek(instrumentos,arch);
                     write(instrumentos,loddatosinst);
                     close(instrumentos);
                     break;
                  end
               else
                  begin
                  close(instrumentos);
                  break;
                 end;
              end;
           end;
        end;
     end;
  end;
 
 
   procedure menu;
   var
      tecl : char;
      sal : boolean;
    begin
       sal := false;
     repeat
        clrscr;
        writeln('   **** Menu Jeneral ****');
        writeln;
        writeln('  1 = Entrada Cliente');
        writeln('  2 = Entrada Instrumento');
        writeln('  3 = Mostrar Todo El Archivo Clientes');
        writeln('  4 = Mostrar Todo El Archivo Instrumentos');
        writeln('  5 = Mostrar Un Cliente');
        writeln('  6 = Mostrar Un Instrumento');
        writeln('  7 = Anula Un Cliente');
        writeln('  8 = Anula Un Instrumento');
        writeln('  9 = Salir');
        repeat
            tecl := readkey;
        until tecl in['1','2','3','4','5','6','7','8','9'];
    case tecl of
 '1' : begin
          clrscr;
          entre_datos('C');
       end;
 '2' : begin
          clrscr;
          entre_datos('I');
       end;
 '3' : begin
          clrscr;
          presenta_archivo('C');
       end;
 '4' : begin
          clrscr;
          presenta_archivo('I');
       end;
 '5' : begin
         clrscr;
         muestra_un_cliente_o_instrumento('C');
       end;
 '6' : begin
         clrscr;
         muestra_un_cliente_o_instrumento('I');
       end;
 '7' :  begin
          clrscr;
          anular_cliente_o_instrumento('C');
        end;
 '8' : begin
          clrscr;
          anular_cliente_o_instrumento('I');
        end;
 '9' : sal := true;
   end;
     until sal = true;
    end;
 
 
   begin
       num_user := 0;
       num_inst := 0;
       menu;
   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