Back to List
Placeholder | Replace With |
text | A text value, such as a Text variable |
text | The character or character string for which you want to search |
The position expression finds the position of a certain character or character string in a given text value. It is useful if you need to find a character you know will be in an answer but are not sure where it will appear. It returns a number value, which represents the first character.
The following script finds the hyphen in the variable, CaseNumber, and returns a number value, representing its numeric position in that given text string.
position( CaseNumber, "-" )
In the next example, the position expression is used as part of a larger computation to test whether a given time falls after 5:30 P.M. The position expression locates the colon (:) in the time value so HotDocs can process the text before and after the colon to find the correct result:
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
This script first determines if the value of CallTime is in the afternoon (P.M.). If it is, the script uses the position expression to locate the first non-digit character (the colon) so the integer expression can convert all of the digit characters leading up to it into a numeric value.
Once identified, 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. The hours and minutes 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