home *** CD-ROM | disk | FTP | other *** search
/ Oakland CPM Archive / oakcpm.iso / sigm / vol285 / brief-ts.how < prev    next >
Encoding:
Text File  |  1986-12-22  |  5.7 KB  |  221 lines

  1.       Last revision: May 15, 1986 at 16:08
  2.  
  3. file: BRIEF-TS.HOW - instructions for adding time/date stamps to Brief
  4. by: H.M. Van Tassell - a no rights reserved public Domain donation...
  5.                                                                  
  6. In the BRIEF Editor version 1.31 from the UnderWare Inc. (gosh, sure
  7. wish I had thought of that neat name!), a function was added that will
  8. get the DOS system date and time. I thought it would be nice to time
  9. stamp certain files  such as "C", Pascal, dBASE etc.  The code below
  10. when added to the files STARTUP.M and  SYSTEM.M and then recompiled by
  11. using >CM STARTUP will make a new Brief STARTUP.CM that automatically
  12. adds a time stamp with the proper remark symbols for the file of type
  13. ".C & .H", ".PRG", ".PAS", ".M", ".ASM", or ".PRG". In other files just
  14. hit the F10 key and invoke the "today" macro to get a time stamp at the
  15. then current cursor position.
  16.  
  17. If the words "Last revision:" are on the first line of a file it will
  18. be updated by the "write_it" macro in SYSTEM.M.
  19.  
  20. *********************>>>>> changes to file STARTUP.M <<<<< ***************
  21.  
  22. >>>>>> Look for this in the STARTUP.M file as your position finder <<<<<<
  23.         (extended)     <----
  24.     )                      <----
  25. )                              <----
  26. >>>> This next code replaces all the code to the end of the file STARTUP.M <<<<<
  27.  
  28.       ;**   This next macro will either over-write or insert a
  29.       ;**   Last revision: date & time on the first line of a buffer.
  30.       ;**   It is the callers duty to put the comment symbol in front
  31.       ;**   of the new line.
  32.  
  33. (macro today
  34.    (
  35.       (string month_string rev_msg rev_time)
  36.       (int year month day hours minutes)
  37.         (date year month day month_string)
  38.       (time hours minutes)
  39.       (sprintf rev_msg "   Last revision: %s %d, %d" month_string day year)
  40.       (if (< minutes 10)
  41.         (sprintf rev_time " at %d:0%d" hours minutes)
  42.       ;else
  43.         (sprintf rev_time " at %d:%d" hours minutes)
  44.       )
  45.       (+= rev_msg rev_time)
  46.       (insert rev_msg)
  47.    )
  48. )
  49.  
  50. (macro no_date
  51.    (
  52.       (int found)
  53.       (move_abs 1 1)
  54.       (search_string "Last revision:" (read) found)
  55.       (returns (! found))
  56.    )
  57. )
  58.  
  59.  
  60. ;**    The following macros are called when files with their names as
  61. ;**    extensions are read into buffers.
  62.  
  63. ;**        This macro, which is called when a file with a .c extension is read
  64. ;**    into a buffer, sets the tabs.
  65. ;**
  66. ;**        Note that the (tabs) macro primitive replicates the distance of the
  67. ;**    last tab stop until the end of the line.
  68.  
  69.  
  70. (macro .c
  71.    (
  72.       (if (no_date)
  73.          (
  74.            (insert "\n")
  75.            (move_abs 1 1)
  76.            (insert "/* ")
  77.            (today)
  78.            (insert "  */\n")
  79.          )
  80.       )
  81.        (tabs 4 7)
  82.    )
  83. )
  84.  
  85. (macro .h
  86.     (.c)                                ;** same as a c file.
  87. )
  88.  
  89. (macro .m
  90.    (
  91.       (if (no_date)
  92.          (
  93.            (move_abs 1 1)
  94.            (insert "\;** ")
  95.            (today)
  96.            (insert "\n")
  97.          )
  98.       )
  99.        (tabs 4 7)
  100.    )
  101. )
  102.  
  103. (macro .asm
  104.    (
  105.       (if (no_date)
  106.          (
  107.            (insert "\n")
  108.            (move_abs 1 1)
  109.            (insert "\; ")
  110.            (today)
  111.            (insert "\n")
  112.          )
  113.       )
  114.        (tabs 9 17)
  115.    )
  116. )
  117.  
  118. (macro .prg
  119.    (
  120.       (if (no_date)
  121.          (
  122.            (insert "\n")
  123.            (move_abs 1 1)
  124.            (insert "** ")
  125.            (today)
  126.            (insert "\n")
  127.          )
  128.       )
  129.         (tabs 3 5 7 9 11 13 15)    ;** Tabs for dBase III source code
  130.    )
  131. )
  132.  
  133. (macro .pas
  134.    (
  135.       (if (no_date)
  136.          (
  137.            (insert "\n")
  138.            (move_abs 1 1)
  139.            (insert "(* ")
  140.            (today)
  141.            (insert "  *)\n")
  142.          )
  143.       )
  144.        (tabs 4 7)
  145.    )
  146. )
  147.  
  148. ;**
  149. ;**    The next macro is called if the extension of the file does not match
  150. ;**    any of the previous macros (".h", ".c", ".m", ".asm", ".prg", ".pas").
  151. ;**
  152.  
  153. (macro default
  154.     (tabs 9 17)     ;** By default, use assembler-style tabs.
  155. )
  156. ;[eof] STARTUP.M 
  157.  
  158. *********************>>>> end of changes to file SYSTEM.M <<<<<*************
  159.  
  160. *************************>>>>> Changes to file SYSTEM.M <<<<<****************
  161.  
  162. >>>>> Replace the write_it macro in the file SYSTEM.M with this code <<<<<
  163.  
  164. ;**
  165. ;**        write_it:
  166. ;**
  167. ;**    This macro decides what to do when Alt-w is pressed -- if a block
  168. ;**    is marked, then the "write_block" primitive is called.  Otherwise,
  169. ;**    write_buffer is called to write out the entire buffer.
  170. ;**
  171.  
  172. (macro write_it
  173.     (
  174.         (int        old_msg_level)
  175.  
  176.         (= old_msg_level (inq_msg_level))
  177.         (set_msg_level 0)
  178.  
  179.         (if (inq_marked)
  180.             (write_block)
  181.         ;else
  182.          (
  183.             (if (inq_modified)
  184.                (
  185.                   (int c_symbol p_symbol c_line c_col)
  186.                   (inq_position c_line c_col)
  187.                   (if (! (no_date))    ;** if there is a time stamp
  188.                       (
  189.                          (move_abs 1 1)
  190.                          (search_string "/*" (read 2) c_symbol)
  191.                          (search_string "(*" (read 2) p_symbol)
  192.                          (move_abs 1 4)
  193.                          (delete_to_eol)
  194.                          (today)       ;** update the time stamp
  195.                          (if c_symbol (insert "  */"))
  196.                          (if p_symbol (insert "  *)"))
  197.                       )
  198.                   )
  199.                   (move_abs c_line c_col)
  200.                )
  201.             )
  202.                (write_buffer)
  203.          )
  204.         )
  205.         (set_msg_level old_msg_level)
  206.     )
  207. )
  208. ******************>>>> end of changes to file SYSTEM.M <<<<<************** 
  209. >>>> Use this as your position finder so you know where write_it ends <<<<
  210. ;**                             <----
  211. ;**        next_word:      <----
  212. ;**                             <----
  213. ;**        Locates the next word in the file using a regular expression.  If
  214. ;**    there are no following words in the file, the cursor does not move.
  215. ;**                             <----
  216.  
  217. [ end of file BRIEF-TS.HOW ]
  218.  
  219.  
  220.  
  221.