No logro compilar, problema con la libreria
Publicado por Santiago (3 intervenciones) el 27/08/2013 01:07:39
No logro hacer funcionar mi programa, alguien puede pegarle una compilada y decirme cual puede ser el error, la libreria compila perfectamente pero el programa principal me tira error. Dejo los codigos:
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
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
Unit SecRV;
Interface
uses dos, sysutils, crt;
Const
TamBloque = 512;
CapacBloque = TamBloque - SizeOf(Word);
PorcCarga = 0.75;
EmpleadoFin = 'fin';
DelString = '|';
DelCampo = '#';
DelReg = '@';
Type
tFecha = Record
D: Integer;
M: Integer;
A: Integer;
end;
regHijos = Record
FNac: tFecha;
Nomb: string;
end;
regEmp = Record
Legajo: string;
ApNomb: string;
Conyuge: string;
h: integer;
hijos: Array [1..15] of regHijos;
end;
tEmp = String;
tBloque = Record
cantRegs: Word;
contenido: Array[1..CapacBloque] of Byte
end;
Modo = (esc, lecOesc);
tEmpleados = Record
arch: File of tBloque;
espLibre: File of Word;
m: Modo;
bloque: tBloque;
iBloque: Word;
espLibreBloque: Word
end;
Procedure Abrir(var A: tEmpleados);
Procedure Cerrar(var A: tEmpleados);
Procedure Crear(var A: tEmpleados);
Procedure Cargar(var A: tEmpleados; E: tEmp);
Procedure Agregar(var A: tEmpleados; E: tEmp);
Procedure Primero(var A: tEmpleados; var E: tEmp);
Procedure Siguiente(var A: tEmpleados; var E: tEmp; var inicio: Boolean);
Procedure Obtener(var A: tEmpleados; Le: string; var E: tEmp; var result: Boolean);
Procedure Eliminar(var A: tEmpleados; Le: string; E: tEmp; var result: Boolean);
Procedure Modificar(var A: tEmpleados; Le: string; var E: tEmp; var result: Boolean);
Procedure CargarDesde(var A: tEmpleados{; NomBase: String});
Procedure GenRegistro(var E: tEmp; R: regEmp);
Procedure ProcRegistro(E: tEmp; var R: regEmp);
Procedure AltaEmp(var A: tEmpleados);
Procedure StrToDate(s: string; var f: tFecha);
Procedure DateToStr(f: tFecha; var s: string);
Procedure CargaFecha(var F1: tFecha; F2: tFecha);
Procedure LeeLegajo(E: tEmp; var Le: String);
Procedure EliminarHijosMayores(var A: tEmpleados);
Procedure Reporte(var A: tEmpleados);
Procedure ListarEnTxt(var A: tEmpleados);
Procedure EsMayor(F1: tFecha; F2: tFecha; var result: Boolean);
(**********************************************************************************)
Implementation
procedure Abrir(var A: tEmpleados);
begin
With A do begin
Reset(arch);
Reset(espLibre);
m:=lecOesc
end;
end;
procedure Cerrar(var A: tEmpleados);
begin
With A do begin
If m = esc then
If A.bloque.cantRegs>0 then
With A do begin
Write(arch, bloque);
Write(espLibre, espLibreBloque);
end;
Close(arch);
Close(espLibre);
end;
end;
procedure Crear(var A:tEmpleados);
begin
With A do begin
Rewrite(arch);
Rewrite(espLibre);
m:=esc;
bloque.cantRegs:=0;
iBloque:=1;
espLibreBloque:=CapacBloque;
end;
end;
procedure Cargar(var A: tEmpleados; E: tEmp);
var
tamReg: Byte;
disponibles: Integer;
begin
tamReg:= Length(E)+1;
disponibles:= A.espLibreBloque-Round((1-PorcCarga)*CapacBloque);
If tamReg > disponibles then
with A do begin
write(arch, bloque);
write(espLibre, espLibreBloque);
bloque.cantRegs:= 0;
espLibreBloque:= CapacBloque;
iBloque:= 1;
end;
with A do begin
Move(E, bloque.contenido[iBloque], tamReg);
Inc(iBloque, tamReg);
Inc(bloque.cantRegs);
Dec(espLibreBloque, tamReg);
end;
end;
procedure Agregar(var A: tEmpleados; E: tEmp);
var
tamReg: Byte;
libres: Word;
disponibles: Integer;
begin
with A do begin
seek(espLibre, 0);
tamReg:= Length(E)+1;
Repeat
Read(espLibre, libres);
disponibles:= libres - Round((1 - PorcCarga) * CapacBloque);
until eof(espLibre) or (disponibles >= tamReg);
If tamReg > disponibles then begin
bloque.cantRegs:= 0;
libres:= CapacBloque;
iBloque:= 1;
seek(arch, FileSize(arch));
end
else begin
seek(arch, FilePos(espLibre)-1);
read(arch, bloque);
iBloque:= CapacBloque - libres + 1;
seek(arch, FilePos(espLibre) - 1);
seek(espLibre, FilePos(espLibre) - 1);
end;
Move(E, bloque.contenido[iBloque], tamReg);
Inc(bloque.cantRegs);
Dec(libres,tamReg);
write(arch, bloque);
write(espLibre, libres);
end
end;
procedure Primero(var A: tEmpleados; var E: tEmp);
var
tamReg: Byte;
begin
With A do begin
Seek(arch, 0);
Read(arch, bloque);
tamReg:=bloque.contenido[1]+1;
Move(bloque.contenido[1], E, tamReg);
iBloque:=tamReg+1;
Seek(espLibre,0);
Read(espLibre, espLibreBloque);
end;
end;
procedure Siguiente(var A: tEmpleados; var E: tEmp; var inicio: Boolean);
var
tamReg: Byte;
begin
With A do begin
If (iBloque>CapacBloque-espLibreBloque) and (not eof(arch)) then begin
Read(arch, bloque);
iBloque:=1;
Read(espLibre, espLibreBloque);
inicio:= True;
end
else
inicio:= False;
If iBloque<CapacBloque-espLibreBloque then begin
tamReg:=bloque.contenido[iBloque]+1;
Move(bloque.contenido[iBloque], E, tamReg);
Inc(iBloque, tamReg);
end
else E := EmpleadoFin;
end;
end;
procedure Obtener(var A: tEmpleados; Le: string; var E: tEmp; var result: Boolean);
var
inic: Boolean;
Leg: string;
begin
with A do begin
Primero(A,E);
LeeLegajo(E, Leg);
while (E <> EmpleadoFin) and (Leg <> Le) do begin
Siguiente(A, E, inic);
LeeLegajo(E, Leg);
end;
If Leg = Le then
result:= True
else
result:= False
end
end;
procedure Eliminar(var A: tEmpleados; Le: string; E: tEmp; var result: Boolean);
var
resObt: Boolean;
resto: word;
tamReg: Byte;
begin
Obtener(A, Le, E, resObt);
If resObt then
with A do begin
resto:= CapacBloque - espLibreBloque -iBloque + 1;
tamReg:= Length(E)+1;
If resto > 0 then
move(bloque.contenido[iBloque], bloque.contenido[iBloque-tamReg], resto);
Dec(bloque.cantRegs);
Inc(espLibreBloque, tamReg);
seek(arch, FilePos(arch)-1);
write(arch, bloque);
seek(espLibre, espLibreBloque);
result:= True;
end
else
result:= False
end;
procedure Modificar(var A: tEmpleados; Le: string; var E: tEmp; var result: Boolean);
var
resObt: Boolean;
resto: word;
tamReg: Byte;
E2: tEmp;
begin
E2:='';
Obtener(A, Le, E2, resObt);
If resObt then
with A do begin
resto:= CapacBloque - espLibreBLoque - iBloque + 1;
tamReg:= Length(E2)+1;
If resto > 0 then
move(bloque.contenido[iBloque], bloque.contenido[iBloque-tamReg], resto);
Inc(espLibreBloque, tamReg);
iBloque:= CapacBloque - espLibreBloque + 1;
tamReg:= Length(E)+1;
If tamReg > espLibreBloque then begin
seek(arch, FilePos(arch) - 1 );
write(arch, bloque);
seek(espLibre, FilePos(espLibre)-1);
write(espLibre, espLibreBloque);
Agregar(A,E);
end
else begin
move(E, bloque.contenido[iBloque], tamReg);
Dec(espLibreBloque, tamReg);
seek(arch, FilePos(arch)-1);
write(arch, bloque);
seek(espLibre, FilePos(espLibre)-1);
write(espLibre, espLibreBloque);
end;
result:= True;
end
else
result:= False
end;
Procedure ProcRegistro(E: tEmp; var R: regEmp);
var
i, j: integer; aux: string; fecha: tFecha;
begin
i:= 1;
with R do begin
while E[i] <> '#' do begin
Legajo:= Legajo + E[i];
inc(i);
end;
inc(i);
while E[i] <> '#' do begin
ApNomb:= ApNomb + E[i];
inc(i);
end;
inc(i);
while E[i] <> '#' do begin
aux:= aux + E[i];
inc(i);
end;
h := StrToInt(aux);
If h > 0 then begin
for j:= 1 to h do begin
inc(i);
while E[i] <> '#' do begin
aux:= aux + E[i];
inc(i);
end;
StrToDate(aux, fecha);
CargaFEcha(hijos[j].FNac, fecha);
inc(i);
while E[i] <> '#' do begin
hijos[j].Nomb:= hijos[j].Nomb + E[i];
inc(i);
end;
end;
end;
end;
end;
Procedure LeeLegajo(E: tEmp; var Le: String);
var
i: Integer;
begin
i := 1; Le := '';
while E[i] <> '#' do begin
Le:= Le + E[i];
inc(i);
end;
end;
Procedure GenRegistro(var E: tEmp; R: regEmp);
var
i: integer; aux: string;
begin
E:='';
with R do begin
E:= E + Legajo;
E:= E + '#';
E:= E + ApNomb;
E:= E + '#';
E:= E + Conyuge;
E:= E + '#';
If h <> 0 then begin
for i := 1 to (h - 1) do begin
DateToStr(hijos[i].FNac, aux);
E:= E + aux;
E:= E + '#';
E:= E + hijos[i].Nomb;
E:= E + '#';
end;
DateToStr(hijos[h].FNac, aux);
E:= E + aux;
E:= E + '#';
E:= E + hijos[h].Nomb;
E:= E + '@';
end
else
E:= E + '0@';
end;
writeln(E);
readln();
end;
Procedure EsMayor(F1: tFecha; F2: tFecha; var result: Boolean);
begin
If F1.A > F2.A then
result:= False
else
If F1.A < F2.A then
result:= True
else
If F1.M > F2.M then
result:= False
else
If F1.M < F2.M then
result:= True
else
If F1.D > F2.D then
result:= False
else
result:= True;
end;
Procedure EliminarHijosMayores(var A: tEmpleados);
var
F: tFecha; Em: tEmp; Reg: regEmp; i, j: integer; result, inic: Boolean; aux: string;
begin
writeln('Ingrese la fecha límite (DDMMAAAA): ');
readln(aux);
StrToDate(aux, F);
with F do
A:= A - 21;
Primero(A, Em);
while Em <> EmpleadoFin do begin
ProcRegistro(Em, Reg);
with Reg do begin
If h > 0 then
for i:= 1 to h do begin
EsMayor(hijos[i].FNac, F, result);
If result then
for j:= i to h do begin
CargaFecha(hijos[j].FNac,hijos[j+1].FNac);
hijos[j].Nomb := hijos[j+1].Nomb;
end;
end;
end;
Siguiente(A, Em,inic);
end;
end;
Procedure Reporte(var A: tEmpleados);
var
Reg: regEmp; Em: tEmp; inic: Boolean; i: Integer;
SC, CC : Array[1..15] of Integer;
begin
for i:= 0 to 15 do begin
SC[i] := 0;
CC[i] := 0;
end;
Primero(A, Em);
while Em <> EmpleadoFin do begin
ProcRegistro(Em, Reg);
with Reg do begin
If Conyuge = '' then
SC[h] := SC[h] + 1
else
CC[h] := CC[h] + 1;
end;
Siguiente(A, Em,inic);
end;
i:= 0;
writeln('Reporte');
writeln('Total Empleados sin conyuge y sin hijos: ',SC[i]);
writeln('Total Empleados con conyuge y sin hijos: ',CC[i]);
for i:= 1 to 15 do begin
writeln('Total de Empleados sin conyuge y con ',i,' hijos: ',SC[i]);
writeln('Total de Empleados con conyuge y con ',i,' hijos: ',CC[i]);
end;
end;
Procedure AltaEmp(var A: tEmpleados);
var
rEmpleado: regEmp;i: integer; aux: string; Em: tEmp;
begin
clrscr;
Writeln('Alta Empleado'); writeln;
with rEmpleado do begin
writeln('Ingrese Nro. de Legajo: '); read(Legajo);
writeln('Ingrese Apellido y Nombre: '); read(ApNomb);
writeln('Ingrese Nombre del Conyuge: '); read(Conyuge);
writeln('Ingrese Cantidad de Hijos: '); read(h);
If h > 0 then
for i:= 1 to h do begin
writeln('Ingrese Fecha de Nacimiento (DDMMAAAA): '); read(aux);
StrToDate(aux, hijos[i].FNac);
writeln('Ingrese Nombre: '); read(hijos[i].Nomb);
end;
end;
GenRegistro(Em, rEmpleado);
Agregar(A, Em);
end;
Procedure StrToDate(s: string; var f: tFecha);
var
aux: string;
begin
with f do begin
aux:= '';
aux:= aux + s[1];
aux:= aux + s[2];
D := StrToInt(aux);
aux:= '';
aux:= aux + s[3];
aux:= aux + s[4];
M := StrToInt(aux);
aux:= '';
aux:= aux + s[5];
aux:= aux + s[6];
aux:= aux + s[7];
aux:= aux + s[8];
A := StrToInt(aux);
end;
end;
Procedure DateToStr(f: tFecha; var s: string);
var
aux: String;
begin
aux:= '';
s:= '';
with f do begin
aux:= IntToStr(D);
s:= s+ aux;
aux:= IntToStr(M);
s:= s+ aux;
aux:= IntToStr(A);
s:= s+ aux;
end;
end;
Procedure CargaFecha(var F1: tFecha; F2: tFecha);
begin
with F1 do begin
D:= F2.D;
M:= F2.M;
A:= F2.A;
end;
end;
Procedure ListarEnTxt(var A: tEmpleados);
var
Em: tEmp; inic: Boolean; Arch: Text; i: integer; aux: string; Reg: regEmp;
begin
Primero(A, Em);
Assign(Arch, 'Reporte.txt');
Rewrite(Arch);
writeln('Reporte Datos Empleados');
writeln;
while Em <> EmpleadoFin do begin
ProcRegistro(Em, Reg);
with Reg do begin
writeln('Apellido y Nombre Empleado: ',ApNomb);
writeln('Nro de Legajo: ', Legajo);
writeln;
If Conyuge <> '' then
writeln('Conyuge: ',Conyuge);
If h > 0 then
writeln;
writeln('Hijo/s');
for i:= 1 to h do begin
writeln('Nombre: ',hijos[i].Nomb);
DateToStr(hijos[i].FNac, aux);
writeln('Fecha de Nacimiento: ', aux);
writeln;
end;
end;
Siguiente(A, Em,inic);
end;
end;
Procedure CargarDesde(var A: tEmpleados{; NomBase: String});
var
ArchEmp: Text;
Linea: String;
Emp: tEmp;
t, i, h, n: integer;
begin
Assign(ArchEmp, 'CargaInicial.txt');
reset(ArchEmp);
while not EOF(ArchEmp) do begin
Linea:=''; {proceso un empleado}
Emp:= '';
readln(ArchEmp, Linea); {Numero de Legajo y Nombre}
t:= Length(Linea); Inc(t);
i:= 1;
while i < t do begin
while Linea[i] <> '|' do begin
Emp:= Emp + Linea[i];
Inc(i);
end;
Emp:= Emp + '#';
Inc(i);
end;
readln(ArchEmp, Linea); {Nombre Conyuge}
t:= Length(Linea); Inc(t);
i:= 1;
if t > 0 then begin
while i < t do begin
Emp:= Emp + Linea[i];
Inc(i);
end;
Emp:= Emp + '#';
end;
readln(ArchEmp, Linea); {Cantidad de Hijos}
h:= StrToInt(Linea);
if h = 0 then
Emp:= Emp+'0@'
else begin
Dec(h);
For n := 0 to h do begin
readln(ArchEmp, Linea); {Fecha de Nacimiento y Nombre}
t:= Length(Linea); Inc(t);
i:= 1;
while i < t do begin
while Linea[i] <> '|' do begin
Emp:= Emp + Linea[i];
Inc(i);
end;
Emp:= Emp + '#';
Inc(i);
end;
readln(ArchEmp, Linea); {Fecha de Nacimiento y Nombre Ultimo Hijo}
t:= Length(Linea); Inc(t);
i:= 1;
while i < t do begin
while Linea[i] <> '|' do begin
Emp:= Emp + Linea[i];
Inc(i);
end;
Emp:= Emp + '@';
end;
Cargar(A, Emp); {Agrego el Registro al Archivo}
Writeln(Emp);
end;
close(ArchEmp);
writeln;
readln();
end;
end;
end;
End.
Valora esta pregunta


0