yosoysupercholo

programa agenda

Oct 19th, 2011
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 4.44 KB | None | 0 0
  1. ::programa agenda
  2. @echo off
  3. :MENU
  4. CLS
  5. echo   *------------------------*   Fecha: %DATE%  - Hora: %TIME%
  6. echo   * Bienvenido a la agenda *
  7. echo   *                        *
  8. echo   *   Eliga una opcion     *
  9. echo   *------------------------* & echo.
  10. echo   1. Listar contactos
  11. echo   2. Nuevo contacto
  12. echo   3. Borrar contacto
  13. echo   4. Buscar contacto
  14. echo   5. Modifcar contacto
  15. echo   6. Borrar agenda
  16. echo   7. Numero de contactos
  17. echo   8. SALIR & echo.
  18. set /P opcion="_Introduzca el numero deseado: "
  19. if %opcion% EQU 1 (goto :LISTAR)
  20. if %opcion% EQU 2 (goto :NUEVO)
  21. if %opcion% EQU 3 (goto :BORRARCONTACTO)
  22. if %opcion% EQU 4 (goto :BUSCAR)
  23. if %opcion% EQU 5 (goto :MODIFICAR)
  24. if %opcion% EQU 6 (goto :BORRARAGENDA)
  25. if %opcion% EQU 7 (goto :NUMERO_CONTACTOS)
  26. if %opcion% EQU 8 (goto :SALIR)
  27. if %opcion% LEQ 0 (goto :ERROR) else if %opcion% GEQ 9 (goto :ERROR)
  28. ::#########################ERRORES#########################
  29. :ERROR
  30. CLS & echo. & echo     ERROR - Debe introducir un valor numero correcto & echo. & @PAUSE & goto :MENU
  31. :VACIO
  32. echo. & echo El directorio esta vacio & echo.
  33. echo  Regresando al menu principal...
  34. echo. & @PAUSE & goto:MENU
  35. :NO_EXISTE
  36. echo  ERROR - El contacto no existe & echo.
  37. echo  Regresando al menu principal...
  38. echo. & @PAUSE & goto:MENU
  39. ::#########################ERRORES#########################
  40. :LISTAR
  41. CLS & echo     -= Listando el directorio =- & echo.
  42. if NOT EXIST directorio.txt (goto :VACIO) else (type directorio.txt|find /V /N "todo")
  43. echo. & @PAUSE & goto :MENU
  44. :NUEVO
  45. CLS & echo     -=Agregar un nuevo contacto=- & echo.
  46. set /P nombre="_Nombre: "
  47. set /P apellidos="_Apellido: "
  48. set /P telefono="_Telefono: "
  49. echo %nombre% %apellidos% %telefono% >> directorio.txt
  50. echo. & echo  Se ha agregado a: %nombre% %apellidos% %telefono%
  51. echo. & @PAUSE & goto :MENU
  52. :BORRARCONTACTO
  53. CLS & echo     -=Borrar contacto=- & echo.
  54. echo  Que desea hacer?
  55. echo   1. Listar todos los contactos
  56. echo   2. Buscar un contacto
  57. echo   3. Borrar directamente un contacto
  58. echo   4. Volver al menu principal & echo.
  59. set /P desea="_Introduzca el numero deseado: " & echo.
  60. if %desea% EQU 1 (goto :BORRARCONTACTO_LISTAR)
  61. if %desea% EQU 2 (goto :BORRARCONTACTO_BUSCAR)
  62. if %desea% EQU 3 (goto :BORRARCONTACTO_DIRECTAMENTE)
  63. if %desea% EQU 4 (goto :MENU)
  64. if %desea% LEQ 0 (goto :ERROR) else if %desea% GEQ 5 (goto :ERROR)
  65. :BORRARCONTACTO_LISTAR
  66. if NOT EXIST directorio.txt (goto :VACIO) else (type directorio.txt) & echo.
  67. goto :BORRARCONTACTO_DIRECTAMENTE
  68. :BORRARCONTACTO_BUSCAR
  69. if NOT EXIST directorio.txt (goto :VACIO) & echo.
  70. set /P buscalo="_Escriba el contacto a buscar: "
  71. echo.
  72. type directorio.txt|find "%buscalo%">nul
  73. if %ERRORLEVEL% EQU 0 (type directorio.txt|find "%buscalo%") else (goto :NO_EXISTE)
  74. goto :BORRARCONTACTO_DIRECTAMENTE
  75. :BORRARCONTACTO_DIRECTAMENTE
  76. echo.
  77. if NOT EXIST directorio.txt (goto :VACIO) & echo.
  78. set /P eliga="_Escriba el telefono del contacto a borrar: "
  79. type directorio.txt|find /v "%eliga%">tmp
  80. type tmp>directorio.txt
  81. del /Q tmp
  82. echo. & echo  El contacto ha sido borrado, el directorio queda asi: & echo.
  83. type directorio.txt
  84. echo. & @PAUSE & goto :MENU
  85. :BUSCAR
  86. CLS & echo     -=Buscar contacto=- & echo.
  87. echo # NOTA: Debe escribir correctamente el contenido a buscar # & echo.
  88. set /P buscar="_Introduzca el Nombre, apellidos o telefono: " & echo.
  89. type directorio.txt|find /I "%buscar%">nul
  90. if %ERRORLEVEL% EQU 0 (type directorio.txt|find /I "%buscar%") else (goto :NO_EXISTE)
  91. echo. & @PAUSE & goto :MENU
  92. :MODIFICAR
  93. CLS & echo     -=Modificar contacto=- & echo.
  94. if NOT EXIST directorio.txt (goto :VACIO) else (type directorio.txt) & echo.
  95. set /P eliga="_Escriba el telefono del contacto a modificar: "
  96. type directorio.txt|find /v "%eliga%">tmp
  97. type tmp>directorio.txt
  98. del /Q tmp
  99. echo. & echo  Introduzca el contacto modificado:
  100. set /P nombre="_Nuevo Nombre: "
  101. set /P apellidos="_Nuevo Apellido: "
  102. set /P telefono="_Nuevo Telefono: "
  103. echo %nombre% %apellidos% %telefono% >> directorio.txt
  104. echo. & echo  Se ha modificado a: %nombre% %apellidos% %telefono%
  105. echo. & @PAUSE & goto :MENU
  106. :BORRARAGENDA
  107. CLS & echo     -=Borrar agenda=- & echo.
  108. if NOT EXIST directorio.txt (goto :VACIO) else (del directorio.txt>nul | echo  Directorio borrado!)
  109. echo. & @PAUSE & goto :MENU
  110. :NUMERO_CONTACTOS
  111. echo. & echo  El numero de contactos de esta agenda es de:
  112. find /V /C "TODO" directorio.txt
  113. echo. & @PAUSE & goto :MENU
  114. :SALIR
  115. CLS & echo. & echo  Abandonando agenda & echo. & @PAUSE & CLS & goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment