HotDocs Tips & Tricks

Tips, tricks and solutions with the HotDocs document assembly platform
Sunday, March 08, 2009

DECREMENT and INCREMENT


The DECREMENT and INCREMENT instructions are relatively new to HotDocs and they serve identical, but reversed purposes.  DECREMENT will reduce a given number variable by one, whereas INCREMENT will increase by one.

These two instructions are most useful in conjunction with WHILE and REPEAT instructions.  Lets say we are doing some real estate templates and one of the templates is ONLY required where there are one or more corporate borrowers. To do this, we could just use a TF variable that is set to TRUE if there is at least one corporate borrower, but that isn’t as useful as knowing exactly how many corporate borrowers we have.  Making MORE specific information available to your system is nearly always better than “the shortest approach”.

SET BORR Corporate CNT TO 0 //our var to store how many corporate borrowers
REPEAT BORROWERS RPT
 
IF BORRS Corporate TF TRUE //a checkbox on the dialog if the borrower is a company
 
INCREMENT BORR Corporate CNT
 END 
IF
END REPEAT

And that’s it.  At the end of this, BORR Corporate CNT will contain the number of corporate borrowers we have.  The same usage would apply in a WHILE statement, except that in a WHILE loop, it is nearly always imperative that you have an INCREMENT (or DECREMENT) statement.  The reason for this is that REPEAT will auto terminate when you have finished the repeated answers whereas WHILE does not - YOU must manually code that ‘cut out’.  And that’s where INCREMENT comes in.

At the end of the day, INCREMENT and DECREMENT could already be achieved in HotDocs scripting as follows:

INCREMENTSET Variable NU TO Variable NU 1
DECREMENT
SET Variable NU TO Variable NU 1

Both of these would work. But these two new instructions are cleaner and easier to type.  And lets face it - convenience and clean code are pretty cool things to have.

Posted by Ian Burrows
Page 1 of 1 pages

Statistics

Page Views: 18008
Page rendered in 0.2713 seconds
34 queries executed
Total Entries: 152
Most Recent Entry: 03/10/2010 06:02 pm
Total Members: 5
Total Logged in members: 0
Total guests: 29
Most Recent Visitor on: 03/11/2010 10:39 pm
Most visitors ever: 46 on 03/04/2010 11:35 am