tlaEventPrepareToSave
Add Date/Time Stamp when Document is Saved

CodeWright® - API Macro - Royalty Free - 2005.01.01 17:15
Send Comments

Purpose

Add Date/Time Stamp when Document is Saved.

Operation

This function automates the process of adding a date/time stamp to a file.

Before a buffer write occurs, this function is called. If the file being written is one of the module types being date/time stamped, the current date/time is inserted appropriately before the document is written to the file.

If the file is being saved with a Save As the comment type of the original (old) file will be used for the comparison.

This function stamps the current date/time into any comment statement that is of the form:

delimiter yyyy.mm.dd hh:mm when delimiter is set from an entry in a table keyed to the extension of the file.

This function calls tlaDateTime and as such will help implement your organization standard date/time stamp.

It is useful to have a "starter" date/time in the template that you use for module creation. If you use the supplied format emitted by tlaDateTime, an example of a "starter" date/time for C# might be:

// 2002.01.01 12:00      Copyright 1993-2005 ...

The document types (file extensions) currently supported by this function are:

Type Map Comment Revision Language
.adb   /*     Ada
.asm   ;     Assembly Language
.asp   <!-- ' TRUE Active Server Page
.awk   /*     Aho, Weinberger, and Weinberger
.bas   '     Basic
.bat   /*     Batch (Shell)
.c   //     C
.ctml   /*     CTML
.cls .bas '      
.cob   *     COBOL
.cpp   //     C++
.cs   //     C#
.ctl .bas '      
.cwb   '     AppBasic Macro (CodeWright)
.cxx   //     C++
.dob .bas '      
.dsr .bas '      
.e   //     Slick-C
.frm .bas '      
.h   //     Header (C)
.hpp   //     Header (C++)
.htm .html <!--   TRUE Hyper Text Markup Language
.html   <!--   TRUE Hyper Text Markup Language
.ini   '     Initialization
.hxx .hpp //     Header (C++)
.jav .java //     Java
.java   //     Java
.js   //     Jscript
.jsp   //     Java Server Page
.mac   //     API Macro (CodeWright)
.mak   #     Make and NMake
.nrx   /*     NetRexx
.pag bas '      
.pas   {     Pascal
.php   /*     PHP: Hypertext Preprocessor
.pl   # // TRUE Perl
.rc   /*     RC
.rul   /*     InstallScript
.sqlj   /*     SQLJ
.tcl   /*     Tcl/Tk
.tk   /*     Tcl/Tk
.txt   /*     Text
.v   /*     Verilog
.vb .bas '     Visual Basic
.vbs   '     VBscript
.vhd   /*     VHDL

Input Parameters

None.

Return Codes

Code Meaning
0 Always returned.

Reference

This function calls tlaDateTime.

This function requires modification to _Init_API_Macro.

Compatibility

Current version verified under:

  • CodeWright 7.0b
  • CodeWright 7.0c
  • CodeWright 7.5.1
  • CodeWright 7.5.2
  • CodeWright for .NET 7.0 supports this as a called function.

CodeWright for .NET Restriction

The automatic updating provided by this function is triggered by an event in CodeWright. Event processing is not available in CodeWright for .NET and as such this function will not automatically update files in that environment. The capability is useful in CodeWright for .NET as a directly called function and it is directly called by tlaWriteBuffer and tlaWriteModifiedBuffer if they are executed in CodeWright for .NET.

CodeWright for .NET Restriction

None.

Installation

There are three primary methods for installing this macro on your system. Method A uses the tlaMDE tool available for purchase from this website. Method B manipulates the macro repository directly. Method C uses the API Macro... tool provided in every copy of CodeWright (but not CodeWright for .NET).

Method A - tlaMDE - CodeWright or CodeWright for .NET

  • Select the Code button on this page.
  • When the second window opens, select all the text in the text box.
  • Issue Ctl-C (copy).
  • Create a new file in CodeWright or CodeWright for .NET.
  • Issue Ctl-V (paste).
  • Issue tlaMDE C (save and compile).

Method B - Copy to Repository - CodeWright or CodeWright for .NET

  • Select the Code button on this page.
  • When the second window opens, select all the text in the text box for a macro.
  • Issue Ctl-C (copy).
  • Load the macro repository "cwright.mac" from your CodeWright or CodeWright for .NET root:
  • issue Ctl-End to go to the end of file.
  • Issue Ctl-V (paste).
  • Close the file and respond yes to the write request.

Method C - API Macro ... - CodeWright Only

  • Select the Code button on this page.
  • When the second window opens, select text from the text box for a macro:
    • Do not select the [API Macro ... header line.
    • Select all other lines in the macro.
  • Issue Ctl-C (copy).
  • Open the CodeWright Tools | API Macros... dialog.
  • Press the New button.
  • Select the Edit box.
  • Issue Ctl-V (paste).
  • Double-click on the function name in the header of the macro.
  • Issue Ctl-C (copy).
  • Select the Name box.
  • Issue Ctl-V (paste).
  • Delete the trailing blank from the name.
  • Select the Save button.
  • Select the Close button.
  • Repeat this process for each macro in the text box.

Update _Init_API_Macro - CodeWright

  • Select the Code button on this page.
  • When the second window opens, select the EventRegister statement in the _Init_API_Macro text box.
  • Issue Ctl-C (copy).
  • Select the appropriate location in your revised _Init_API_Macro macro.
  • Issue Ctl-V (paste).
  • Select all the text in your revised _Init_API_Macro macro.
  • Issue Ctl-C (copy).
  • Open the CodeWright Tools | API Macros... dialog.
  • Select the _Init_API_Macro macro.
  • Select all the text in the Edit box.
  • Issue Ctl-V (paste).
  • Delete the trailling blank from the name.
  • Select the Save button.
  • Select the Close button.

Purchase

tlaTools is a Dynamic Link Library that contains most of the API macros on this website in a single easy to install package. The tlaTools DLL can be purchased by selecting the Buy button on this page.

tlaEventPrepareToSave is included as a function in tlaTools.

Copyright © 1993-2005 Thom Little Associates, Ltd. revised 2005.01.01 17:15
One Central Square, Keene, NH 03431-3787 phone 603-357-7567