Here is the code snippet, which would help in locating the line number in a string control which has got multiple lines.
static void gotoLineNum(FormStringControl _control, int _gotoLine)
{
int lineCount;
int i;
int gotoLineNum;
int lengthTotal;
int selectToPos;
str lineText;
#define.SPACE(' ')
lineCount = _control.getLineCount();
gotoLineNum = _gotoLine;
for (i = 0; i<= lineCount-1; i++)
{
if (i == gotoLineNum-1)
{
break;
}
if (i == 0)
{
lineText = #SPACE + _control.getLine(i);
}
else
{
lineText = strRep(#SPACE, 2) + _control.getLine(i) ;
}
lengthTotal += strLen(lineText);
}
lineText = #SPACE + _control.getLine(i);
selectToPos = lengthTotal + strLen(lineText);
lengthTotal = (i==0) ? 0 : lengthTotal+1;
_control.setSelection(lengthTotal, selectToPos);
_control.setFocus();
}