Board index » delphi » DESPERATELY need HELP (BUFFERS)

DESPERATELY need HELP (BUFFERS)

Hi,

Please help me figure out how to get a buffer functioning which will
allow me to work on a selected area of text (in a MEMO) in excess of
255 characters.

What I am trying to do is Select a section (anywhere from a single
word up to several paragraphs), and then upon clicking the Button I
want the SelText (selected text) to be left in place with another
short Text String before and after the SelText. Kind of like creating
an HTML tag: ie:
"My Text Here which could be many paragraphs"
would become:
<TAG>"My Text Here which could be many paragraphs"</TAG>

I had considered using clipboard (cut, paste etc) but then that would
constantly be deleting any text which the user wanted to keep in the
clipboard. SO I want to use the BUFFER function.

I am sooo close to completing my first application, and have stumbled.
When reading all the online help I come up with the following
attempts:

procedure TForm1.ButtonClick (Sender: Tobject);
       var
        Buffer: PChar;
        Size: Integer;
       begin
        Size := Memo1.SelLength;
        Inc(Size);
        GetMem(Buffer, Size);
        Memo1.GetSelTextBuf(Buffer, Size);
        Memo1.SelText := 'New Text A.. ' + StrPas(Buffer) + '   Second
Text insert';
        FreeMem(Buffer, Size);
        end;

But, while it does count the number of characters, (I had it
displaying the Size to be sure of that), and it does insert the 'New
Text A.. ' it does not make use of a buffer and therefore still only
adds the 'Second Text Insert' on selected areas below 255 characters.

Can someone see what I am doing wrong, and be kind enough to correct
my code so that I can accomplish this.

Thanks.

Martin.

Free HTML Helper available for Downloading, from:
http://web.ukonline.co.uk/members/mek/helper.htm

Martin Koss (mk...@bigfoot.com)
NO SPAM _EVER_.
Any problems with HTML Helper, let me know.

 

Re:DESPERATELY need HELP (BUFFERS)


If you are using Delphi 2.0, the help file recommends that you
type cast the pchar instead of using StrPas. ( ex: String(Buffer) )

hope it helps.

regards,
joe chizmas

Re:DESPERATELY need HELP (BUFFERS)


Hawx Software Solutions <h...@earthling.net> wrote in article
<3342F01D.2...@earthling.net>...

Quote
> If you are using Delphi 2.0, the help file recommends that you
> type cast the pchar instead of using StrPas. ( ex: String(Buffer) )

Specifically, I seem to recall that StrPas is hard-coded to only handle 255
characters!

Other Threads