"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "vil96w32/dates.rc" of archive vile-w32.zip:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 ; $Header: /usr/build/vile/vile/macros/RCS/dates.rc,v 1.2 2001/09/24 00:24:39 tom Exp $
    2 
    3 ; These macros illustrate the use of the &date function.
    4 
    5 ; Insert/update a timestamp at the first place in the file with "Last updated:",
    6 ; or similar text.  Bound this to F19 (which is shift-F9 on xterm) to show the
    7 ; difference between an insert-binding and a regular binding.
    8 store-procedure InsertTimestamp
    9 	~local $curcol $curline $ignorecase $search
   10 	~local %label %stamp %length
   11 	setv %label='\<last \(update\|change\)[d]\?:'
   12 	setv %stamp=&date '%Y/%m/%d %H:%M:%S' &stime
   13 	setl ignorecase
   14 	goto-beginning-of-file
   15 	~force search-forward %label
   16 	~if &seq $match ''
   17 		write-message 'InsertTimestamp - fail'
   18 	~else
   19 		write-message 'InsertTimestamp - ok'
   20 		setv %length &sub &add $curcol &len $match 1
   21 		goto-bol
   22 		setv $line &cat &left $line %length &cat ' ' %stamp
   23 	~endif
   24 ~endm
   25 bind-insmode-key InsertTimestamp #-(
   26 
   27 ; Show the date/time when the file was last modified.
   28 store-procedure ShowTimestamp
   29 	write-message &cat 'File last modified: ' &date '%Y/%m/%d %H:%M:%S' &ftime $cbufname
   30 ~endm
   31 bind-key ShowTimestamp #-9 
   32 
   33 ; Make a write-hook (if the buffer is modified, the macro will change the
   34 ; last-updated field before writing).
   35 store-procedure UpdateTimestamp
   36 	~if $modified
   37 		InsertTimestamp
   38 	~endif
   39 ~endm
   40 setv $write-hook UpdateTimestamp