Link to home
Start Free TrialLog in
Avatar of light_bulb
light_bulbFlag for United States of America

asked on

Variable required error when using TMemoryStream.WriteBuffer

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...
ASKER CERTIFIED SOLUTION
Avatar of dinilud
dinilud
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of light_bulb

ASKER

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?
What is "clRichText" . Is it a record or a class or RichTextComponent?
Avatar of rambolivia
rambolivia

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!!!
Nice explanation
Understood.  Thank you very much!