Board index » delphi » About Collection

About Collection

Could anyone tell me: 'How to copy a collection'?

My program will run on a very simple PC (without HD and EMS), so I can't
use any kind of streams.
My problem is: I must pass a collection to an object to edit it.
If the user press 'Cancel', the collection must be restored by it's
original value. So I guess I gota make a copy of the collection. but...
... How to make a copy of a collection ???

Jason

 

Re:About Collection


Quote
Jason wrote:

> Could anyone tell me: 'How to copy a collection'?

> My program will run on a very simple PC (without HD and EMS), so I can't
> use any kind of streams.
> My problem is: I must pass a collection to an object to edit it.
> If the user press 'Cancel', the collection must be restored by it's
> original value. So I guess I gota make a copy of the collection. but...
> ... How to make a copy of a collection ???

> JasonThe only way to copy a collection is to create a new collection, create

new Objects and copy the attributes from each object in the new object.

Re:About Collection


In a previous article, Jason <jason...@ms2.hinet.net> wrote:

Quote
>Could anyone tell me: 'How to copy a collection'?

>My program will run on a very simple PC (without HD and EMS), so I can't
>use any kind of streams.

Who says you can't use streams?  You can use a stream on a floppy disk
or in the RAM that the computer does have.  You will undoubtedly find
it helpful to take a look at Duncan Murdoch's "Streams" unit.  It is
available at ftp//garbo.uwasa.fi in one of the pascal directories.
Look for "Stream16.zip".  It _may_ be in the TurboVision directory.

Quote
>My problem is: I must pass a collection to an object to edit it.
>If the user press 'Cancel', the collection must be restored by it's
>original value. So I guess I gota make a copy of the collection. but...
>... How to make a copy of a collection ???

>Jason

You don't have to use a stream to make the copy.  As a matter of fact,
if that was all you were going to use streams for, DON'T use a stream:
it just links in a lot of code that really is not necessary.  All you need to
do is 1.) initialize a new TCollection
      2.) make a copy of each of the items in the original and insert it
            into the new collection.
If you could create the original in the first place, creating the back-up
copy shouldn't be too hard.

Rob

Other Threads