LAST Function
The LAST function finds and returns the number of characters you specify from the end of the text string you specify.
You use this function when you want to extract the last portion of a text value, if, for example, you wanted to include only the last four digits of a Social Security number in a document.
Function name |
LAST |
Usage model | LAST ( in:TEXT, count:NUM ) |
Parameters | This function requires you to replace two parameters: |
in: TEXT |
The function returns a specified number of the last characters of the text value. |
count: NUM |
This parameter specifies the amount of characters which the function will return. |
Result | A text value. |
Example
The following expression uses the LAST function to return the last four digits of a Social Security number:
LAST( SocialSecurityNumber, 4 )
In the next example, the assembled document needs to make the answer of ItemType plural. Using the LAST function, along with IF and ELSE instructions, HotDocs checks to see if the last letter in the value is a specific letter. If so, HotDocs inserts the correct plural suffix.
IF LAST( ItemType, 1 ) = "s" OR LAST( ItemType, 1 ) = "z" ItemType + "es" ELSE ItemType + "s" END IF
This example script does not take into consideration words that end in "y" or "x" or any other letter that would cause yet a different result. It is only shown here in its most basic form to demonstrate how the LAST function works.