top of page

28. Auto-Expiring Template

Description

Makes a template "expire" 30 days after the first use or after 30 uses.

Code

// First see if there is already an entry
// Do it by reading INIKEY and checking if it has a value
INIKEY( "win.ini" , "HotDocs" , "ExpDate" )
IF RESULT != ""
// There was an entry;
// Translate it into a temporary date variable
// and compare it to TODAY
SET Expiration-d TO DATE OF(
INTEGER( MID( RESULT , 3 , 2 ) ) ,
INTEGER( FIRST( RESULT , 2 ) ) ,
INTEGER( LAST( RESULT , 4 ) )
)
IF DAYS FROM( Expiration-d , TODAY ) > 30
// Yup, it's expired . . .
ASK NONE
ELSE
// Nope, it's not expired!
END IF

ELSE
// There wasn't an entry, so make one
// in the format mmddyyyy
SET INIKEY("win.ini" , "HotDocs" , "ExpDate" ) TO FORMAT( TODAY , "06031990" )
END IF

Explanation

This computation checks for an expiration date in an .ini file ("win.ini" here).

If there is an expiration date in the .ini file, the computation extracts it and converts it into a HotDocs date (the .ini file entry is just a text string). It then compares that date to TODAY to see if X number of days have passed (in our case, 30). If so, the template "aborts" (sort of) by using an ASK NONE. Otherwise, assembly can proceed as normal.

If an expiration date is not found in the .ini file, and entry is created and the date 30 days away is placed in it.

To modify this for your needs, you'll want to change the INIKEY lines. The three parameters are 1) the .ini file name, 2) the section name, and 3) the value name. In place of "win.ini" you might supply your own file name. If the file doesn't exist it will be created in your Windows directory (c:\windows or c:\winnt). Instead of "HotDocs" for the section name, you might give a name such as "Expirations". And instead of "ExpDate", you'll probably want to use the template name. As with the .ini file name, if the section and value lines do not exist, they will be created. A sample "hotdocs.ini" file's contents follow:

[Expirations]
PowerOfAttorney=01012000
LivingWill=12252000
Nondisclosure=10312000

The INIKEY lines for these entries would be:

INIKEY("hotdocs.ini" , "Expirations" , "PowerOfAttorney" )
INIKEY("hotdocs.ini" , "Expirations" , "LivingWill" )
INIKEY("hotdocs.ini" , "Expirations" , "Nondisclosure" )

bottom of page