Returning the number of character positions text will occupyΒΆ
textlength() |
Return the number of character positions text will occupy |
SYNTAX
textlength(text, text_font, data_font)
Returns the number of positions that the specified text will occupy, if it is displayed using the font text_font in a window whose font is data_font.
The font strings should use the standard Sculptor font specification syntax.
The function returns the value in pixels if the program is using pixel positioning, otherwise in characters.
Note that if the text is a field, the function returns a value for the entire contents of the field, including trailing spaces, unless the field is a temporary field with the flag v (store as variable length). See Field flags.
EXAMPLES
tmp.Chars = textlength("It's the end of the world as we know it", \
"helvetica,b@12", "arial,b@11")
!temp DataFont,,a50
DataFont = "arial@8"
!function GetTextLength(String) {
!temp StrLen,,i2
!temp TextLen,,i2
StrLen = strlen(String)
TextLen = textlength(getstr(String, 1, StrLen), DataFont, DataFont)
return TextLen
}
RELATED TOPICS |