The HotDocs Computation Archive
Get Extra Help

0028 - Auto-Expiring Template

Description:

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


• Explanation •

With HotDocs Pro, you can set a "fixed" expiration date for a template but not a "relative" expiration date (like 30 days from the first use). Moreover, you cannot set an expiration counter (like 30 uses).

Using a computation it is possible to set a relative expiration date or an expiration counter. The computations rely on the INIKEY model to write an expiration date or counter to a Windows .ini file, and then use ASK NONE to "abort" assembly if the template has expired. It is recommended that you also lock the component file to keep the computations from being altered.

The computation below demonstrates how this is done for an expiration date. The model template has working versions of both types.


•  •  •  •  •  •  •


• 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" )

•  •  •  •  •  •  •

 

• Model Template •

This template has everything you need set up and configured for you. It will work as-is, or can be adapted to your variable and dialog names. It contains: 1) sample Word and WordPerfect templates (or an Automator form) to demonstrate an implementation of the computation, 2) a component file containing the computation and all supporting dialogs and variables, and 3) instructions for adapting the computation for your use.

(Go to the download page)

 
 

• Contributors •

LegalCS