?
Solved

Variable required error when using TMemoryStream.WriteBuffer

Posted on 2007-07-26
6
Medium Priority
?
359 Views
Last Modified: 2010-04-04
What is wrong with this code:

            srcStream.WriteBuffer(clRichText.RichText, Length(clRichText.RichText));

I get a 'variable required' error when compiling.  This seems to meet the requirements for TMemoryStream.WriteBuffer...
0
Comment
Question by:light_bulb
  • 3
  • 2
6 Comments
 
LVL 10

Accepted Solution

by:
dinilud earned 2000 total points
ID: 19574321
var S:String;
begin
  S:=clRichText.RichText;
  srcStream.WriteBuffer(S, Length(S));
end;
0
 
LVL 3

Author Comment

by:light_bulb
ID: 19574412
Why do I have to use another string as a variable?  Why won't the compiler let me use clRichText.RichText (which is a string) directly?
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19574474
What is "clRichText" . Is it a record or a class or RichTextComponent?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:rambolivia
ID: 19574590
Hi Light bulb,

If "RichText" is a property you will have to use a variable as dinilub stated.  

This is because the compiler can not take it as a string because there may be a get function, for example, if you have:

property RichText: string read FRichText write FRichText

you may think RichText is a string variable and WriteBuffer should take it as is, but if you change it to:

property RichText: string read GetRichText write SetRichText

even though the property works the same to the outside world, it has internally changed.  Properties can not be used as variables.  WriteBuffer expects a variable which it can point to, properties point to functions.

Hope it helps!!!
0
 
LVL 10

Expert Comment

by:dinilud
ID: 19574656
Nice explanation
0
 
LVL 3

Author Comment

by:light_bulb
ID: 19574682
Understood.  Thank you very much!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question