home *** CD-ROM | disk | FTP | other *** search
/ Share Gallery 1 / share_gal_1.zip / share_gal_1 / GR / GR505.ZIP / LSP.EXE / AUTOSAVE.LSP < prev    next >
Text File  |  1987-12-04  |  6KB  |  196 lines

  1. ; =========================================================
  2. ;   AUTOSAVE.LSP             By:   Jeff Pilcher
  3. ;
  4. ;   This is an AutoLISP routine for use with the
  5. ;   AutoCAD drafting software.
  6. ;
  7. ;   I am providing this routine to other users of
  8. ;   AutoCAD under the SHAREWARE concept. I would
  9. ;   like to recover some of the cost of my time
  10. ;   spent developing this and other AutoLISP
  11. ;   routines for AutoCAD, by asking for voluntary
  12. ;   payments.
  13. ;
  14. ;   If you find this routine is useful to you in
  15. ;   doing paying work, please send $5 to:
  16. ;
  17. ;              Jeffrey S. Pilcher
  18. ;
  19. ;              Production Systems
  20. ;              P.O. Box 218
  21. ;              Richmond, IL  60071
  22. ;
  23. ;              (815) 678-4562
  24. ;
  25. ;   Obviously $5 is not going to make me rich, or break
  26. ;   your bank account.  It will however, show me that
  27. ;   someone out there appreciates my efforts, and give
  28. ;   me the incentive to write more useful routines.
  29. ;
  30. ;   I would be very interested in seeing any routines
  31. ;   written by you or anyone else. In other words, an
  32. ;   exchange of routines would make me as happy as a
  33. ;   $5 payment, (well, almost as happy).
  34. ;
  35. ;   Feel free to pass this routine on to other AutoCAD
  36. ;   users, but PLEASE, do not remove these comments.
  37. ;
  38. ;   Good luck, have fun, and LONG LIVE AutoDESK !!!
  39. ;
  40. ; =========================================================
  41. ;
  42. ;
  43. ;   This is a routine to automatically save your drawing at
  44. ;   regular intervals during the editing session.
  45. ;
  46. ;   There are a lot of autosave routines out there, but I think
  47. ;   this is the most straight forward of the bunch.
  48. ;
  49. ;   AUTOSAVE.LSP main features:
  50. ;
  51. ;          1) Can be turned on or off as you see fit.
  52. ;
  53. ;          2) You specify how often you want to AUTOSAVE.
  54. ;
  55. ;          3) When it is not time to AUTOSAVE, it tells
  56. ;             you how much time is left so you know exactly
  57. ;             what is happenning.
  58. ;
  59. ;          4) When it is AUTOSAVING, it tells you the name
  60. ;             of the drawing being AUTOSAVED.
  61. ;
  62. ;   INSTALLATION:
  63. ;
  64. ;     To utilize this routine you should include the code portion
  65. ;     in your ACAD.LSP file.
  66. ;
  67. ;     After you have installed AUTOSAVE.LSP in your ACAD.LSP file
  68. ;     you will need to include the command "(c:setauto)" as the
  69. ;     last statement in your ACAD.LSP file.  This will cause
  70. ;     AutoCAD to prompt the user with the message:
  71. ;
  72. ;         Do you want to do AUTOSAVES ?
  73. ;
  74. ;     upon entering the drawing editor.
  75. ;
  76. ;     Then include the command AUTOSAVE  under many of the menu
  77. ;     picks in your tablet menu.
  78. ;
  79. ;
  80. ;   OPERATION:
  81. ;
  82. ;     When you enter the drawing editor, and as the ACAD.LSP
  83. ;     file is being loaded, the operator will be asked if he/she
  84. ;     would like to do AUTOSAVES:
  85. ;
  86. ;          Do you want to do AUTOSAVES ?
  87. ;
  88. ;     A response of [ y ] or [ Y ] will turn AUTOSAVE on, AutoCAD
  89. ;     will tell the operator that AUTOSAVE is on with the prompt:
  90. ;
  91. ;          AUTOSAVE is on.
  92. ;
  93. ;     Any other response will turn AUTOSAVE off, AutoCAD will
  94. ;     tell the operator that AUTOSAVE is off with the prompt:
  95. ;
  96. ;          AUTOSAVE is off.
  97. ;
  98. ;     If the operator has chosen to do AUTOSAVES by responding
  99. ;     [ y ] or [ Y ] he/she will be asked how often to AUTOSAVE
  100. ;     with the prompt:
  101. ;
  102. ;          How often would you like to AUTOSAVE, in minutes <15>:
  103. ;
  104. ;     The operator should at this time enter a number indicating
  105. ;     how often they would like AutoCAD to AUTOSAVE thier drawing.
  106. ;     The default is 15 minutes. If 15 minutes is acceptable,
  107. ;     simply hit <ENTER>.
  108. ;
  109. ;     Upon picking one of the tablet picks which contains the
  110. ;     AUTOSAVE command, AutoCAD will check to see how long it has
  111. ;     been since it last AUTOSAVED your drawing.  If the time
  112. ;     since the last AUTOSAVE has exceeded the desired interval,
  113. ;     AutoCAD will automatically save your drawing for you, and
  114. ;     tell you what is happenning with the prompt:
  115. ;
  116. ;          AUTOSAVING:  <dwgname>
  117. ;          Please stand by ....
  118. ;
  119. ;     (never again will you loose 4 hours of work due to a systems
  120. ;     crash or power failure).
  121. ;
  122. ;     If the time since the last AUTOSAVE has not exceeded the
  123. ;     desired interval, AutoCAD will tell you with the prompt:
  124. ;
  125. ;          Not time yet .... xx.x minutes left.
  126. ;
  127. ;     As you can see, it will tell how much time is left until the
  128. ;     next AUTOSAVE.
  129. ;
  130. ;
  131. ;   EXTRA FEATURES:
  132. ;
  133. ;     The AUTOSAVE routine can be turned on or off at any time you
  134. ;     desire while in the drawing editor by typing [ SETAUTO ], at
  135. ;     the command prompt, and answering the prompt:
  136. ;
  137. ;          Do you want to do AUTOSAVES ?
  138. ;
  139. ;     with the proper response. This prompt is the same prompt you
  140. ;     get when you first enter the drawing editor. Therefore you
  141. ;     will also be asked to enter a time interval for the AUTOSAVE
  142. ;     program. So not only can you turn AUTOSAVVES on or off, but,
  143. ;     you can also change the time interval whenever you like.
  144. ;
  145. ;
  146.  
  147. (defun c:setauto ()
  148.   (setq answer (strcase (getstring "\nDo you want to do AUTOSAVES ?  ")))
  149.   (if (> (strlen answer) 1)
  150.     (setq answer (substr answer 1 1))
  151.   )
  152.   (if (= answer "Y")
  153.     (progn
  154.       (prompt "\nAUTOSAVE is on.")
  155.       (print)
  156.       (setq minutes (getreal "\nHow often would you like to AUTOSAVE, in minutes <15>: "))
  157.       (if (= minutes nil)
  158.         (setq minutes 15.0)
  159.       )
  160.     )
  161.     (prompt "\nAUTOSAVE is off.")
  162.   )
  163.   (print)
  164. )
  165. (defun C:autosave ()
  166.   (if (= answer "Y")
  167.     (saveit)
  168.     (prompt "\nAUTOSAVE is turned off !")
  169.   )
  170.   (print)
  171. )
  172. (defun saveit ()
  173.   (if (= D1 nil)
  174.     (setq D1 (getvar "DATE"))
  175.   )
  176.   (if (> (* (- (getvar "DATE") D1) 1440.0) minutes)
  177.     (progn
  178.       (setvar "cmdecho" 0)
  179.       (prompt (strcat "\nAUTOSAVING:  " (getvar "dwgname")))
  180.       (prompt "\nPlease stand by .... ")
  181.       (print)
  182.       (command "SAVE" "")
  183.       (prompt "\nAUTOSAVE complete.")
  184.       (prompt "\nThank you for waiting.")
  185.       (setq D1 (getvar "DATE"))
  186.       (setvar "cmdecho" 1)
  187.     )
  188.     (progn
  189.       (prompt "\nNot time yet .... ")
  190.       (princ (rtos (- minutes (* (- (getvar "DATE") D1) 1440.0)) 2 1))
  191.       (princ " minutes left.")
  192.     )
  193.   )
  194.   (print)
  195. )
  196.