Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-10

Something goes wrong while streaming nested components

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Kiên Nguyễn Tiến Trung

I have been successful to save a component to a text file. However, I have a problem while reading them back.

To illustrate, this is the text file created by saving the components.

object Parent1: TParentClass
Child = Child
Value = 54
Str = 'SP'
List.Strings = (
'PV'
)
object Child: TChildClass
Value = 85
Str = 'WO'
List.Strings = (
'QL'
)

  end

end

When I load the component Parent1 using this file, properties Value, Str, and List are loaded successfully. *However, the property Child is not loaded.*

It seems that there is a TChildClass object created and then increases the ComponentCount of Parent1. But it is not what I want. I want the property Child be loaded instead of creating a new object.

-------------------------------------

Please download the attachment to see how it acts. The way to reproduce is described as following:

1. Press RandButton, then press ShowButton, the message should look like this:
Parent: Value=54, Str=SP, List=PV, ComponentCount=1 Child: Value=85, Str=WO, List=QL, ComponentCount=0

2. Press SaveButton

3. Close the form and reopen it.

4. Press LoadButton, then press ShowButton, the message should look like this:
Parent: Value=54, Str=SP, List=PV, ComponentCount=2 Child: Value=0, Str=, List=, ComponentCount=0
(What I expected is
Parent: Value=54, Str=SP, List=PV, ComponentCount=1 Child: Value=85, Str=WO, List=QL, ComponentCount=0)

I spent about 12 hours to find out the proper way but I failed. Please help me. Thanks in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151017/d60bfb1f/attachment.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: streaming_components.zip
Type: application/zip
Size: 3999 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151017/d60bfb1f/attachment.zip>

Reply by email

Mattias Gaertner
to Kiên Nguyễn Tiến Trung
Show quoted text 24 lines
I have been successful to save a component to a text file. However, I have a problem while reading them back. To illustrate, this is the text file created by saving the components. object Parent1: TParentClass Child = Child Value = 54 Str = 'SP' List.Strings = ( 'PV' ) object Child: TChildClass Value = 85 Str = 'WO' List.Strings = ( 'QL' ) end end When I load the component Parent1 using this file, properties Value, Str, and List are loaded successfully. *However, the property Child is not loaded.*

Actually it is created and loaded.

It seems that there is a TChildClass object created and then increases the ComponentCount of Parent1. But it is not what I want. I want the property Child be loaded instead of creating a new object.

If I remember correctly you need

Child.ComponentStyle:=Child.ComponentStyle+[csSubComponent];

Mattias

Reply by email

Kiên Nguyễn Tiến Trung
to Mattias Gaertner

Thank you.
V?o 18-10-2015 22:11, "Mattias Gaertner" ??
vi?t:

Show quoted text 50 lines
On Sat, 17 Oct 2015 15:18:12 +0700 Ki?n Nguy?n Ti?n Trung wrote: > I have been successful to save a component to a text file. However, I have > a problem while reading them back. > > To illustrate, this is the text file created by saving the components. > > object Parent1: TParentClass > Child = Child > Value = 54 > Str = 'SP' > List.Strings = ( > 'PV' > ) > object Child: TChildClass > Value = 85 > Str = 'WO' > List.Strings = ( > 'QL' > ) > end > end > > When I load the component Parent1 using this file, properties Value, Str, > and List are loaded successfully. *However, the property Child is not > loaded.* Actually it is created and loaded. > It seems that there is a TChildClass object created and then increases the > ComponentCount of Parent1. But it is not what I want. I want the property > Child be loaded instead of creating a new object. If I remember correctly you need Child.ComponentStyle:=Child.ComponentStyle+[csSubComponent]; Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20151026/7bb21769/attachment.html>

Reply by email