Back to List
Placeholder | Replace With |
text | A text value, such as a Text variable |
Sometimes you may have a text value that contains number characters, as in the case of a time of day value. The integer expression allows you to convert those number characters into numeric values so you can perform calculations or compare them with other values.
The integer expression searches the beginning of a text string for number characters and converts those it finds to numeric values. When it encounters a non-number character (such as a letter or punctuation mark) it stops processing the instruction.
For example, if you tried to find the integer of the word cat, the integer expression would return 0 (zero) since there are no number characters in cat. However, if you used integer on the text value 12:30, it would return the number value 12 since those characters are numbers. (As explained earlier, it stops processing when it reaches a punctuation mark, which in this case is a colon.)
One of the main uses for the integer expression is to compare time values. In the following computation, HotDocs is attempting to determine if a given time value falls after 5:30 P.M. Because time values are text values, the Text variable, Call Time TE, must first be converted to an integer before it can be used in the comparison:
if CallTime contains "p"
integer( CallTime ) + ( integer( mid( CallTime, 1 + position( CallTime, ":" ), 2 ) ) /60 ) > 5.5
else
integer( CallTime) + ( integer( mid( CallTime, 1 + position( CallTime, ":" ), 2 ) ) /60 ) > 17.5
endIf
In this script, CallTime is a Text variable with a 24-hour or 12-hour time pattern (99:99 or 99:99 A.M.). HotDocs first determines if CallTime is in the afternoon (P.M.). If it is, the script uses the integer expression to convert all the digit characters up to the first non-digit character (the colon) into a numeric value. This number represents the hours portion of the total time. Using the mid expression to locate the two digit characters after the colon, it also converts these characters into an integer and divides the value by 60. This number represents the minutes portion of the total time. These two numbers are added together, and if the result is greater than 5.5 (the equivalent of 5:30), the result is true. If the result is not greater than 5.5, the result is false.
The second portion of the script (after the else expression) performs the same functions on a non-afternoon time value—that is, one that is either in 24-hour format or in the morning (A.M.).
Back to List