Atached code count to positon when specific string in text is present.
But in text i can have more times same text is present:
example:one two three four five one six seven one
1. If i positon cursor on the end of text then my result must be " 0 " and not " 38 "
(number of characters to first time srched string is used).
2.if there is no srched string in text i need to set a bolean varible "noText" to true.
3. if i have two lines when i put curor on the begining of second line it gives me two characters more than on the end of first line
What to do to resolve point 1,2 and 3?
procedure TForm1.Button1Click(Sender: TObject);
var cp: Integer;
p := Pos(Edit1.Text, Memo1.Lines.Text) + Length(Edit1.Text);
cp := Memo1.SelStart;
if cp >= p then
Edit2.Text := IntToStr((cp - p)+1)
Edit2.Text := 'what should be here?';