Tmemo possible bug lazarus / 31-LCL ---------------------------------------------------------------------- Sigismund · 2012-09-09 13:07 Hi guys, I'm not programing expert, I know freepascal basics from school and I use it sometimes to create some useful simple tools. I would like to ask you what am I doing wrong, or if it is a bug of some sort. I need to paste some predefined text into a memo on cursor position. I'm using this code: Code: [Select]var carriage:Tpoint;   line,linestart,lineend,linemid:string;   A,LINELENG:integer; begin   linemid:='loremipsum';   carriage:=memo1.CaretPos;   line:=memo1.lines[carriage.y];   LINELENG:=length(line);   for A:=0 to carriage.x do linestart:= (linestart + line[A]);   for A:=(carriage.x + 1) to LINELENG do lineend:= (lineend + line[A]);   line := (linestart + linemid + lineend);   memo1.lines[carriage.y] := line;    //this doesn't work   label2.caption:=line;    //this works end;      Let's say, that there is the text "ab" on first line of memo1. When I place cursor between a and b, and execute code, I get empty memo and in label "aloremipsumb", which is my desired output. According to info from debugger: Code: [Select]line=''Why label has no problem with it and shows variable correctly? Also memo works fine until text changes, those lines works perfectly as well> Code: [Select]  line:=memo1.lines[carriage.y];    memo1.lines.clear;   memo1.lines[carriage.y] := line;                                    Is it a bug of memo, or is there some char-to-string conversion needed? Thank you ---------------------------------------------------------------------- taazz · 2012-09-09 13:37 How about simple doing. Code: [Select]uses ...., Clipbrd; Procedure PasteInCursorPos(const aMemo:TMemo; const newData:String); begin   Clipboard.AsText:= NewData;   aMemo.PasteFromClipboard;   Clipboard.Clear; end; that is if I understand you correctly didn't read all your message sorry. ---------------------------------------------------------------------- howardpc · 2012-09-09 13:41 Quote from: Sigismund on September 09, 2012, 03:07:59 pm  carriage:=memo1.CaretPos;   line:=memo1.lines[carriage.y]; You are trying to use a caret coordinate position in pixels as an index into an array of strings in a memo. These two have no correspondence or relationship. Howard ---------------------------------------------------------------------- ludob · 2012-09-09 13:46 Or even simpler: Code: [Select]memo1.SelText:=linemid;