I found out some time ago, that string->pad[0] to pad[3] contain the number of lines of the string(It is not documented. Because it is unofficial it might change in future versions of 3dgs). Some examples
"line1\nline2\line3" -> pad[0-3] = 3
"line1" -> pad[0-3] = 1
This is faster then checking every character of a string for a new-line.
Because linecount is an integer, only the 4 first bytes of pad are copied(that's what we want, becuase there the line count of the string is located)