Sign in Join

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

Mailing lists / lazarus / 2022-10

Can I delete a property from a collectionitem

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

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

nibbikfrans

Hi,

I have a collection stored in a file. One property of each collectionitem is a value of what seeems to be a set but is not. That property is no longer needed. Is there a way to delete that property? I suppose I can do that by creating a new collectionitem type without that property and migrate the data. But then a have a different collection which meens a have to make lots of changes.
If deleting a property isn't possible, how can I delete the value of that property?

And an extra question is: how can I test whether the property has a value or not?

The possible value is defined as followes:
TTest = (test1, test2, test3);
TTestValues = set ot TTest;
mvg Frans van Leeuwen M 06-51695390 -- Dit e-mailbericht is met AVG-antivirussoftware gecontroleerd op virussen. www.avg.com

Reply by email

Michael Van Canneyt
to nibbikfrans
nibbikfrans wrote 9 lines
Hi, I have a collection stored in a file. One property of each collectionitem is a value of what seeems to be a set but is not. That property is no longer needed. Is there a way to delete that property? I suppose I can do that by creating a new collectionitem type without that property and migrate the data. But then a have a different collection which meens a have to make lots of changes.

Yet that is the only correct way.

If you can make a descendent, you can
override the property and simply discard the value when it is set in the setter.

If deleting a property isn't possible, how can I delete the value of that property?

In the file, in the instance of the collectionitem or where ?

Show quoted text 7 lines
And an extra question is: how can I test whether the property has a value or not? The possible value is defined as followes: TTest = (test1, test2, test3); TTestValues = set ot TTest;

The property has a set as value ?

If the set is empty, then the property has no value ? Unless empty value is also a value.

Michael.

Reply by email

Bart
to Michael Van Canneyt
PM Michael Van Canneyt wrote
> I have a collection stored in a file. One property of each collectionitem is > a value of what seeems to be a set but is not. That property is no longer > needed. Is there a way to delete that property?

If you mean that it should not be read anymore from the .lfm file (after you changed the code so that it no longer has that property), you can use RegisterPropertyToSkip() (use Find in Files to search for examples).

Bart

Reply by email

Marc Weustink
to Michael Van Canneyt: Yet that is the only correct way. If you can make a descendent, you can override the…
Michael Van Canneyt wrote 19 lines
On Wed, 12 Oct 2022, nibbikfrans via lazarus wrote: > Hi, > > I have a collection stored in a file. One property of each > collectionitem is a value of what seeems to be a set but is not. That > property is no longer needed. Is there a way to delete that property? > I suppose I can do that by creating a new collectionitem type without > that property and migrate the data. But then a have a different > collection which meens a have to make lots of changes. Yet that is the only correct way. If you can make a descendent, you can override the property and simply discard the value when it is set in the setter.

What you also can do is remove the property and override the DefineProperties method of your CollectionItem object and add a dummy reader for your propertyname. This way you will be able to read old data and in new data it won't get written.

I didn't test this on FPC, but I've done it this way several times in Delphi.

Marc

Show quoted text 20 lines
> > If deleting a property isn't possible, how can I delete the value of > that property? In the file, in the instance of the collectionitem or where ? > > And an extra question is: how can I test whether the property has a > value or not? > > The possible value is defined as followes: > TTest = (test1, test2, test3); > TTestValues = set ot TTest; The property has a set as value ? If the set is empty, then the property has no value ? Unless empty value is also a value. Michael.

Reply by email