Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ::programa agenda
- @echo off
- :MENU
- CLS
- echo *------------------------* Fecha: %DATE% - Hora: %TIME%
- echo * Bienvenido a la agenda *
- echo * *
- echo * Eliga una opcion *
- echo *------------------------* & echo.
- echo 1. Listar contactos
- echo 2. Nuevo contacto
- echo 3. Borrar contacto
- echo 4. Buscar contacto
- echo 5. Modifcar contacto
- echo 6. Borrar agenda
- echo 7. Numero de contactos
- echo 8. SALIR & echo.
- set /P opcion="_Introduzca el numero deseado: "
- if %opcion% EQU 1 (goto :LISTAR)
- if %opcion% EQU 2 (goto :NUEVO)
- if %opcion% EQU 3 (goto :BORRARCONTACTO)
- if %opcion% EQU 4 (goto :BUSCAR)
- if %opcion% EQU 5 (goto :MODIFICAR)
- if %opcion% EQU 6 (goto :BORRARAGENDA)
- if %opcion% EQU 7 (goto :NUMERO_CONTACTOS)
- if %opcion% EQU 8 (goto :SALIR)
- if %opcion% LEQ 0 (goto :ERROR) else if %opcion% GEQ 9 (goto :ERROR)
- ::#########################ERRORES#########################
- :ERROR
- CLS & echo. & echo ERROR - Debe introducir un valor numero correcto & echo. & @PAUSE & goto :MENU
- :VACIO
- echo. & echo El directorio esta vacio & echo.
- echo Regresando al menu principal...
- echo. & @PAUSE & goto:MENU
- :NO_EXISTE
- echo ERROR - El contacto no existe & echo.
- echo Regresando al menu principal...
- echo. & @PAUSE & goto:MENU
- ::#########################ERRORES#########################
- :LISTAR
- CLS & echo -= Listando el directorio =- & echo.
- if NOT EXIST directorio.txt (goto :VACIO) else (type directorio.txt|find /V /N "todo")
- echo. & @PAUSE & goto :MENU
- :NUEVO
- CLS & echo -=Agregar un nuevo contacto=- & echo.
- set /P nombre="_Nombre: "
- set /P apellidos="_Apellido: "
- set /P telefono="_Telefono: "
- echo %nombre% %apellidos% %telefono% >> directorio.txt
- echo. & echo Se ha agregado a: %nombre% %apellidos% %telefono%
- echo. & @PAUSE & goto :MENU
- :BORRARCONTACTO
- CLS & echo -=Borrar contacto=- & echo.
- echo Que desea hacer?
- echo 1. Listar todos los contactos
- echo 2. Buscar un contacto
- echo 3. Borrar directamente un contacto
- echo 4. Volver al menu principal & echo.
- set /P desea="_Introduzca el numero deseado: " & echo.
- if %desea% EQU 1 (goto :BORRARCONTACTO_LISTAR)
- if %desea% EQU 2 (goto :BORRARCONTACTO_BUSCAR)
- if %desea% EQU 3 (goto :BORRARCONTACTO_DIRECTAMENTE)
- if %desea% EQU 4 (goto :MENU)
- if %desea% LEQ 0 (goto :ERROR) else if %desea% GEQ 5 (goto :ERROR)
- :BORRARCONTACTO_LISTAR
- if NOT EXIST directorio.txt (goto :VACIO) else (type directorio.txt) & echo.
- goto :BORRARCONTACTO_DIRECTAMENTE
- :BORRARCONTACTO_BUSCAR
- if NOT EXIST directorio.txt (goto :VACIO) & echo.
- set /P buscalo="_Escriba el contacto a buscar: "
- echo.
- type directorio.txt|find "%buscalo%">nul
- if %ERRORLEVEL% EQU 0 (type directorio.txt|find "%buscalo%") else (goto :NO_EXISTE)
- goto :BORRARCONTACTO_DIRECTAMENTE
- :BORRARCONTACTO_DIRECTAMENTE
- echo.
- if NOT EXIST directorio.txt (goto :VACIO) & echo.
- set /P eliga="_Escriba el telefono del contacto a borrar: "
- type directorio.txt|find /v "%eliga%">tmp
- type tmp>directorio.txt
- del /Q tmp
- echo. & echo El contacto ha sido borrado, el directorio queda asi: & echo.
- type directorio.txt
- echo. & @PAUSE & goto :MENU
- :BUSCAR
- CLS & echo -=Buscar contacto=- & echo.
- echo # NOTA: Debe escribir correctamente el contenido a buscar # & echo.
- set /P buscar="_Introduzca el Nombre, apellidos o telefono: " & echo.
- type directorio.txt|find /I "%buscar%">nul
- if %ERRORLEVEL% EQU 0 (type directorio.txt|find /I "%buscar%") else (goto :NO_EXISTE)
- echo. & @PAUSE & goto :MENU
- :MODIFICAR
- CLS & echo -=Modificar contacto=- & echo.
- if NOT EXIST directorio.txt (goto :VACIO) else (type directorio.txt) & echo.
- set /P eliga="_Escriba el telefono del contacto a modificar: "
- type directorio.txt|find /v "%eliga%">tmp
- type tmp>directorio.txt
- del /Q tmp
- echo. & echo Introduzca el contacto modificado:
- set /P nombre="_Nuevo Nombre: "
- set /P apellidos="_Nuevo Apellido: "
- set /P telefono="_Nuevo Telefono: "
- echo %nombre% %apellidos% %telefono% >> directorio.txt
- echo. & echo Se ha modificado a: %nombre% %apellidos% %telefono%
- echo. & @PAUSE & goto :MENU
- :BORRARAGENDA
- CLS & echo -=Borrar agenda=- & echo.
- if NOT EXIST directorio.txt (goto :VACIO) else (del directorio.txt>nul | echo Directorio borrado!)
- echo. & @PAUSE & goto :MENU
- :NUMERO_CONTACTOS
- echo. & echo El numero de contactos de esta agenda es de:
- find /V /C "TODO" directorio.txt
- echo. & @PAUSE & goto :MENU
- :SALIR
- CLS & echo. & echo Abandonando agenda & echo. & @PAUSE & CLS & goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment