Está en la página 1de 3

Archivos

Ing Cristina Alarcón

Operaciones básicas de archivos con organización secuencial: ABM

!Crear un archivo con organización secuencial llamado “alumnos.dat”


Algoritmos crea
Tipo al =registro
Carácter(8) legajo
Carácter(25) appenom
Real nota
Fin
Variables
Tipo(al) alum
Carácter rta
Comienzo
Abrir(2, “C:\ alumno.dat”, Escritura)
Rta Æ ‘ S’
Mientras rta == ‘S’ hacer
Escribir (“Ingrese de teclado”)
Leer (alum.legajo)
Leer (alum. Appenom)
Leer (alum.nota)
Escribir (2, alum) ! Escribe o graba en el disco
Escribir(“desea ingresar otro alumno S/N”)
Leer (rta)
Fin mientras
Cerrar(2)
FIN

! Abrir “alumnos.dat”, ya creado, para lectura


Algoritmo Lectura
Tipo al =registro
Carácter(8) legajo
Carácter(25) appenom
Real nota
Fin
Variables
Tipo(al) alum
Comienzo
Abrir(3, “C:\ alumno.dat”, Lectura)
Mientras NO(EOF( 3) ) hacer
Leer(3, alum)
Procesar ( alum) ! la subrutina Procesar, procesa el registro alum
Fin mientras
Cerrar(3)
FIN

!ALTAS, agregar registros


Algoritmo Altas
Tipo al =registro
Carácter(8) legajo
Carácter(25) appenom
Página 1 de 3
Archivos
Ing Cristina Alarcón
Real nota
Fin
Variables
Tipo(al) alum
Carácter rta
Comienzo
Abrir(2, “C:\ alumno.dat”, Agregar) ! agrega los nuevos registros a continuación de último, donde
coloca el puntero al final del último registro
RtaÅ ‘S’
Mientras rta == ‘ S ‘ hacer
Leer (alum.legajo)
Leer (alum.appenom)
Leer (alum.nota)
Escribir( 2, alum)
Escribir (“ Desea ingresar otra alta S/N “)
Leer (rta)
Fin mientras
Cerrar(2)
Fin

! BAJAS, elimina registros


Algoritmos Bajas
Tipo al =registro
Carácter(8) legajo
Carácter(25) appenom
Real nota
Fin
Variables
Tipo(al) alum
Carácter rta, carácter(25) leg
Comienzo
RtaÅ ‘S’
Mientras rta == ‘S’ hacer
Abrir(2, “C:\ alumno.dat”, Lectura)
Abrir(3, “C:\ auxiliar.dat”, Escritura)
Escribir (“Ingrese el numero de legajo del registro a bajar”)
Leer ( leg)
Mientras NO(EOf(2)) hacer
Leer(2, alum)
Si leg % = alum.legajo entonces
Escribir (3, alum) ! Se supone encuentra el legajo a “bajar”
Fin si
Fin mientras
Escribir(“Desea realizar otra baja S/N’’)
Leer (rta)
Renombrar “auxiliar.dat” como “ alumnos.dat”)
Borrar (3)
Cerrar(2)
Fin mientras
FIN

Página 2 de 3
Archivos
Ing Cristina Alarcón
! MODIFICACIONES

Algoritmo Modificación
Tipo al =registro
Carácter(8) legajo
Carácter(25) appenom
Real nota
Fin
Variables
Tipo(al) alum
Carácter rta, carácter(25) leg
Comienzo
Abrir(2, “C:\ alumno.dat”, Lectura)
Abrir(3, “C:\ auxiliar.dat”, Escritura)
Rta Å ‘S’
Mientras rta == ‘S’ hacer
Escribir (“Ingrese el numero de legajo del registro a modificar”)
Leer ( leg)
Mientras NO(EOf(2)) hacer
Leer(2, alum)
Si leg = = alum.legajo entonces
Modifica(alum) ! Se supone encuentra el legajo a “modificar”
Fin si
Escribir(3,alum)
Fin mientras
Escribir(“Desea realizar otra baja S/N’’)
Leer (rta)
Renombrar “auxiliar.dat” como “alumnos.dat”)
Borrar (3)
Cerrar(2)
Fin mientras
FIN
Subrutina Modifica ( alum)
Variable
Tipo(al) alum, entero op
Comienzo
Escribir (“Ingrese 1- modifica legajo, 2- modifica apellido y nombres, 3- modifica nota”)
Leer (op)
Mientras op >= 1 Y op <= 4 hacer
Según sea (op)
Caso 1: Leer (alum.legajo)
Caso 2: Leer (alum.appenom)
Caso 3: Leer(alum.nota)
Caso 4: Escribir (“ FIN modificaciones”)
Fin segun
Leer(op)
Fin mientras
Fin subrutrina

Página 3 de 3

También podría gustarte