Pascal/Turbo Pascal - la verdad no se cual es el error... ayuda.

 
Vista:

la verdad no se cual es el error... ayuda.

Publicado por jose (4 intervenciones) el 08/11/2014 04:03:45
bueno e estado elaborando este programa en mi clase, pero tengo un error de ultima hora y no consigo cual es o mejor dicho el por que de este error.. el compilador me dice donde es mas no se como solucionarlo aparente mente para mi no tiene error... si alguien me ayuda porfa. dejo indicado en el codigo cual es el error

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
program pastas;
uses crt;
type
 cadena40= string[40];
 trabajador= record
           nombre: string [50];
           calle: string [25];
           ciudad:  string [15];
           codigopostal: string [3];
           correoelectro: string [25];
           edad: integer;
           sw: boolean;
           end;
 fichero= file of trabajador;
var
 arch: fichero;
procedure pulsarunatecla;
var
 car: char;
 begin
  gotoxy(25,23);
  writeln('Pulse Cualquier tecla para continuar');
  car := readkey;
  clrscr
  end;
procedure activar (var f: fichero);
var
 resultado: integer;
begin
  clrscr;
  {$I-}
  reset (f);
  resultado := IOresult;
  {$I+}
  if resultado <>0 then
  rewrite(f);
  close(f)
end;
function posicion (N: cadena40; var f:fichero): integer;
var
 registro : trabajador;
 hallado : boolean;
begin
 hallado := false;
 seek (f, 0);
 while not eof (f) and not hallado do
  begin
   read (f, registro);
   hallado := registro.nombre = n
   end;
 if hallado then
    posicion := filepos (f) - 1
    else
    posicion := 1
 end; {posicion}
 
procedure visualizar ( e: trabajador);
 begin
   with e do
      if e.sw = true then
       begin
          clrscr;
          textcolor(10);
          gotoxy(20,4); writeln ('nombre: ', nombre);
          gotoxy(20,6); writeln ('calle: ', calle);
          gotoxy(20,8); writeln ('ciudad: ', ciudad);
          gotoxy(20,10); writeln ('codigo postal: ', codigopostal);
          gotoxy(20,12); writeln ('correo electronico: ', correoelectro);
          gotoxy(20,14); writeln ('edad: ', edad);
       end;
       pulsarunatecla
      end; {visualizar}
 
procedure leerregistro (var e: trabajador);
var
 resultado: integer;
begin
  with e do
   if e.sw= true then
      begin
       textcolor(15);
       gotoxy(20,10); writeln ('nombre: '); readln(nombre);
       gotoxy(20,12); writeln ('calle: '); readln(calle);
       gotoxy(20,14); writeln ('ciudad: '); readln(ciudad);
       gotoxy(20,16); writeln ('codigo postal: '); readln(codigopostal);
       gotoxy(20,18); writeln ('correo electronico: '); readln(correoelectro);
       gotoxy(20,21); textcolor(15);
       write ('edad: ');
       {$I-}
       readln (edad);
       resultado := IOResult;
       {$I+}
       if resultado <>0 then
         begin
         gotoxy(20,21); textcolor (9);
         write ('para la edad del dato debeser numerico');
         textcolor(15)
         end;
       sw:= true
      end;
     pulsarunatecla
    end;{leer Registro}
 
procedure listadototal (var F: fichero);
var
 e: trabajador;
begin
   reset(f);
 while not eof (f) do
   begin
    clrscr;
    writeln ('registro :',filepos (f)+1:2);
    read (f,e);
    if e.sw= true then
       begin
         visualizar (e)
       end
     else
        begin
         gotoxy(20,7);
         writeln('registro vacio');
         pulsarunatecla
         end
     end;
       close(f)
    end; {listadototal}
 
procedure ampliar (var f: fichero);
var
 r, e : trabajador; I: integer;
 begin
  clrscr; gotoxy(25,2); writeln ('pulse cualquier tecla ecepto N o n');
  while upcase(readkey) <>'N' do
   begin
    clrscr;
    gotoxy(20,4); writeln('introduzca los datos del nuevo registro');
    writeln;
    leerregistro(e);
    i:= posicion (e.nombre, f);
    if i=-1 then
     begin
      i:= filesize(f); seek(f,i); write(f,e)
      end
      else
       begin
        seek(f,i); read(f,r);
        if r.sw= true then
        begin
         clrscr;
         gotoxy(20,36);
         writeln('el elemento ya existe')
         end
        else
         write(f,e)
        end;
        gotoxy(20,37);
        textcolor(12);
        writeln('pulse-n- si quiere salir de la opcion altas');
        textcolor(15)
        end;
        close(f)
      end; {ampliar o agregar datos archivos}
 
procedure borrar (var f: fichero);
var
 e: trabajador;
 i: integer;
 n: cadena40;
begin
 reset(f);
 repeat
 clrscr;
 gotoxy(25,2);
 writeln('esta usted en la opcion de bajas');
 reset (f);
 gotoxy (26,4);
 write ('escriba el nombre del trabajador a borrar: ');
 read(n);
 i:= posicion(n,f);
 if i=-1 then
   begin
    gotoxy(25,4); writeln('no existeel nombre')
    end
   else
    begin
     seek (f,i); read(f,e);
     if e.sw=true then
     visualizar(e);
     e.sw=false   <------------------------aki
     i:=filepos(f)-1;   <-------------------- aki
     write(f,e);
   end;
    gotoxy(20,11); writeln ('pulse -N- si quiere salir de la opcion boja')
    until upcase (readkey) = 'N';
    close(f)
end; {borrar}
 
procedure modificar (var f: fichero);
var
 e: trabajador;
 i: integer;
 n: cadena40;
begin
 reset(f);
 repeat
  gotoxy(25,2);
  writeln('esta usted en la opcion de modificaciones');
  reset(f)
  gotoxy(25,4);
  write ('escriba el nombre del trabajador a modificar: ');
  readln(n);
  i:= posicion (n,f);
  if i=-1 then
   begin
    gotoxy(25,11);
    writeln('no existe el nombre buscado')
    end
   else
    begin
     seek(f,i);
     read(f,e);
     if e.sw= true the
      visualizar(e);
      gotoxy(20,13);
      write('introduzca nuevos datos del registro');
      leerregistro(e);
      i:= filepos(f)-1;
      seek(F,i);
      write(f,e);
      gotoxy(20,11);
      writeln('registro modificado')
      end
     else
      begin
       gotoxy(20,11);
       writeln('el registro fue dado de baja')
      end
     end;
     pulsarunatecla;
     gotoxy(20,23);
     writeln('pulse -n- si quiere salir de la opcion modificaciones')
     until upcase(readkey)= 'N';
   close(f)
 end; {modificar}
 
procedure consulta (var f: fichero);
var
 e: trabajador;
 i: integer;
 n: cadena40;
begin
 reset(f);
 repeat
  gotoxy(25,2);
  writeln('esta usted en la opcion de consulta');
  reset(f)
  gotoxy(25,4);
  write ('escriba el nombre del trabajador a consultar: ');
  readln(n);
  i:= posicion (n,f);
  if i=-1 then
   begin
    gotoxy(25,11);
    writeln('no existe el nombre buscado');
   end
  else
   begin
   seek(e,i);
   read(f,e);
   if e.sw= true then
    begin
    visualizar(e);
    end
   else
   begin
       gotoxy(20,11);
       writeln('el registro fue dado de baja')
      end
   end;
    pulsarunatecla;
    gotoxy(20,23);
     writeln('pulse -n- si quiere salir de la opcion consultar')
     until upcase(readkey)= 'N';
   close(f)
 end; {consultar}
 
procedure menu (var f: fichero);
var
 opcion: char;
begin
       clrscr;
       textcolor(14);
       gotoxy(23,2); writeln ('menu principal'); textcolor(13);
       gotoxy(20,4); writeln ('1.ampliar elemento');
       gotoxy(20,6); writeln ('2.borrar elemento');
       gotoxy(20,8); writeln ('3.modificar elemento');
       gotoxy(20,10); writeln ('4.consultar elemento');
       gotoxy(20,12); writeln ('5.lista total');
       gotoxy(20,14); writeln ('6.salir del programa');
       textcolor(2);
       gotoxy(20,20);
       write('elija una opcion: ');
       textcolor(14);
       repeat
        opcion:= readkey
       until opcion in ['1'..'6'];
        clrscr;
       case opcion of
        '1': ampliar(f);
        '2': borrar(f);
        '3': modificar(f);
        '4': consultar(f);
        '5': listatotal(f);
       end
      until opcion= '6';
    end; {menu}
 
begin {programa principal}
 clrscr;
 assign (arch, 'trabajador.dat');
 activar (arch);
 menu (arch)
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
sin imagen de perfil

la verdad no se cual es el error... ayuda.

Publicado por David (224 intervenciones) el 08/11/2014 10:11:45
Te dejo aquí el error corregido y el comentario del por qué. Al intentar compilarlo han salido más errores, pero esos te los dejo para tí, ya que si estás aprendiendo y te los solucionamos todos aquí no avanzarás

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
program pastas;
uses crt;
type
cadena40= string[40];
trabajador= record
nombre: string [50];
calle: string [25];
ciudad: string [15];
codigopostal: string [3];
correoelectro: string [25];
edad: integer;
sw: boolean;
end;
fichero= file of trabajador;
var
arch: fichero;
procedure pulsarunatecla;
var
car: char;
begin
gotoxy(25,23);
writeln('Pulse Cualquier tecla para continuar');
car := readkey;
clrscr
end;
procedure activar (var f: fichero);
var
resultado: integer;
begin
clrscr;
{$I-}
reset (f);
resultado := IOresult;
{$I+}
if resultado <>0 then
rewrite(f);
close(f)
end;
function posicion (N: cadena40; var f:fichero): integer;
var
registro : trabajador;
hallado : boolean;
begin
hallado := false;
seek (f, 0);
while not eof (f) and not hallado do
begin
read (f, registro);
hallado := registro.nombre = n
end;
if hallado then
posicion := filepos (f) - 1
else
posicion := 1
end; {posicion}
 
procedure visualizar ( e: trabajador);
begin
with e do
if e.sw = true then
begin
clrscr;
textcolor(10);
gotoxy(20,4); writeln ('nombre: ', nombre);
gotoxy(20,6); writeln ('calle: ', calle);
gotoxy(20,8); writeln ('ciudad: ', ciudad);
gotoxy(20,10); writeln ('codigo postal: ', codigopostal);
gotoxy(20,12); writeln ('correo electronico: ', correoelectro);
gotoxy(20,14); writeln ('edad: ', edad);
end;
pulsarunatecla
end; {visualizar}
 
procedure leerregistro (var e: trabajador);
var
resultado: integer;
begin
with e do
if e.sw= true then
begin
textcolor(15);
gotoxy(20,10); writeln ('nombre: '); readln(nombre);
gotoxy(20,12); writeln ('calle: '); readln(calle);
gotoxy(20,14); writeln ('ciudad: '); readln(ciudad);
gotoxy(20,16); writeln ('codigo postal: '); readln(codigopostal);
gotoxy(20,18); writeln ('correo electronico: '); readln(correoelectro);
gotoxy(20,21); textcolor(15);
write ('edad: ');
{$I-}
readln (edad);
resultado := IOResult;
{$I+}
if resultado <>0 then
begin
gotoxy(20,21); textcolor (9);
write ('para la edad del dato debeser numerico');
textcolor(15)
end;
sw:= true
end;
pulsarunatecla
end;{leer Registro}
 
procedure listadototal (var F: fichero);
var
e: trabajador;
begin
reset(f);
while not eof (f) do
begin
clrscr;
writeln ('registro :',filepos (f)+1:2);
read (f,e);
if e.sw= true then
begin
visualizar (e)
end
else
begin
gotoxy(20,7);
writeln('registro vacio');
pulsarunatecla
end
end;
close(f)
end; {listadototal}
 
procedure ampliar (var f: fichero);
var
r, e : trabajador; I: integer;
begin
clrscr; gotoxy(25,2); writeln ('pulse cualquier tecla ecepto N o n');
while upcase(readkey) <>'N' do
begin
clrscr;
gotoxy(20,4); writeln('introduzca los datos del nuevo registro');
writeln;
leerregistro(e);
i:= posicion (e.nombre, f);
if i=-1 then
begin
i:= filesize(f); seek(f,i); write(f,e)
end
else
begin
seek(f,i); read(f,r);
if r.sw= true then
begin
clrscr;
gotoxy(20,36);
writeln('el elemento ya existe')
end
else
write(f,e)
end;
gotoxy(20,37);
textcolor(12);
writeln('pulse-n- si quiere salir de la opcion altas');
textcolor(15)
end;
close(f)
end; {ampliar o agregar datos archivos}
 
procedure borrar (var f: fichero);
var
e: trabajador;
i: integer;
n: cadena40;
begin
reset(f);
repeat
clrscr;
gotoxy(25,2);
writeln('esta usted en la opcion de bajas');
reset (f);
gotoxy (26,4);
write ('escriba el nombre del trabajador a borrar: ');
read(n);
i:= posicion(n,f);
if i=-1 then
begin
gotoxy(25,4); writeln('no existeel nombre')
end
else
begin
seek (f,i); read(f,e);
if e.sw=true then
visualizar(e);
e.sw:=false; {Aquí te faltaban los dos puntos en la asignación y el punto y coma para cerrar la instrucción}
i:=filepos(f)-1;
write(f,e);
end;
gotoxy(20,11); writeln ('pulse -N- si quiere salir de la opcion boja')
until upcase (readkey) = 'N';
close(f)
end; {borrar}
 
procedure modificar (var f: fichero);
var
e: trabajador;
i: integer;
n: cadena40;
begin
reset(f);
repeat
gotoxy(25,2);
writeln('esta usted en la opcion de modificaciones');
reset(f)
gotoxy(25,4);
write ('escriba el nombre del trabajador a modificar: ');
readln(n);
i:= posicion (n,f);
if i=-1 then
begin
gotoxy(25,11);
writeln('no existe el nombre buscado')
end
else
begin
seek(f,i);
read(f,e);
if e.sw= true the
visualizar(e);
gotoxy(20,13);
write('introduzca nuevos datos del registro');
leerregistro(e);
i:= filepos(f)-1;
seek(F,i);
write(f,e);
gotoxy(20,11);
writeln('registro modificado')
end
else
begin
gotoxy(20,11);
writeln('el registro fue dado de baja')
end
end;
pulsarunatecla;
gotoxy(20,23);
writeln('pulse -n- si quiere salir de la opcion modificaciones')
until upcase(readkey)= 'N';
close(f)
end; {modificar}
 
procedure consulta (var f: fichero);
var
e: trabajador;
i: integer;
n: cadena40;
begin
reset(f);
repeat
gotoxy(25,2);
writeln('esta usted en la opcion de consulta');
reset(f)
gotoxy(25,4);
write ('escriba el nombre del trabajador a consultar: ');
readln(n);
i:= posicion (n,f);
if i=-1 then
begin
gotoxy(25,11);
writeln('no existe el nombre buscado');
end
else
begin
seek(e,i);
read(f,e);
if e.sw= true then
begin
visualizar(e);
end
else
begin
gotoxy(20,11);
writeln('el registro fue dado de baja')
end
end;
pulsarunatecla;
gotoxy(20,23);
writeln('pulse -n- si quiere salir de la opcion consultar')
until upcase(readkey)= 'N';
close(f)
end; {consultar}
 
procedure menu (var f: fichero);
var
opcion: char;
begin
clrscr;
textcolor(14);
gotoxy(23,2); writeln ('menu principal'); textcolor(13);
gotoxy(20,4); writeln ('1.ampliar elemento');
gotoxy(20,6); writeln ('2.borrar elemento');
gotoxy(20,8); writeln ('3.modificar elemento');
gotoxy(20,10); writeln ('4.consultar elemento');
gotoxy(20,12); writeln ('5.lista total');
gotoxy(20,14); writeln ('6.salir del programa');
textcolor(2);
gotoxy(20,20);
write('elija una opcion: ');
textcolor(14);
repeat
opcion:= readkey
until opcion in ['1'..'6'];
clrscr;
case opcion of
'1': ampliar(f);
'2': borrar(f);
'3': modificar(f);
'4': consultar(f);
'5': listatotal(f);
end
until opcion= '6';
end; {menu}
 
begin {programa principal}
clrscr;
assign (arch, 'trabajador.dat');
activar (arch);
menu (arch)
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

la verdad no se cual es el error... ayuda.

Publicado por jose (4 intervenciones) el 08/11/2014 18:14:33
listo amigo gracias ya logre que corriera el programa.
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