light_bulb
asked on
Variable required error when using TMemoryStream.WriteBuffer
What is wrong with this code:
srcStream.WriteBuffer(clRi chText.Ric hText, Length(clRichText.RichText ));
I get a 'variable required' error when compiling. This seems to meet the requirements for TMemoryStream.WriteBuffer. ..
srcStream.WriteBuffer(clRi
I get a 'variable required' error when compiling. This seems to meet the requirements for TMemoryStream.WriteBuffer.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What is "clRichText" . Is it a record or a class or RichTextComponent?
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!!!
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
ASKER
Understood. Thank you very much!
ASKER