Fast Copy of instance var's of functional class

forum.centura.team.developer (1998-2005) & forum.sqlwindows (2000-2005)
StefanM
Germany
Posts: 679
Joined: 10 Aug 2018, 15:57
Location: Bavaria

Fast Copy of instance var's of functional class

Post by StefanM » 21 Jan 2005, 16:02

 Posted by:  Stefan Misch 

Hi NG,

is there a "fast" way to copy instance var's from one instance of a
functional class (=FC) to another?

Example:
FC fcFoo with numeric instance vars niOne and string siTwo and maybe more
(but just simple types)
Two instances fooSource and fooTarget of type fcFoo.

I think with
Set fooTarget = fooSource
I just copy "pointers" (or better "object references"), but I do not get an
independent copy.

Do I really need to do something like
Set fooTarget.niOne = fooSource.niOne
Set fooTarget.siTwo = fooSource.siTwo
... all other instance var's
to get a copy? Is there something faster?

What if I add another instance variable to my FC fcFoo. Then I will also
have to modify the Copy( ) function to also include the new instance var.

I know it's Friday, but here I go...

TIA,
Stefan

Ifo

Re: Fast Copy of instance var's of functional class

Post by Ifo » 24 Jan 2005, 09:26

 Posted by:  Ifo 

We are working with Centura 8 years and didn't
found some easy way. We use little workaround -
we create function CopyFrom in functional class
like this:

Functional class: XXX
...
Function: CopyFrom
Description:
Returns
Parameters
class XXX: Src
Static Variables
Local variables
Actions
Set var1 = Src.var1
Set var2 = Src.var2
...

Then, anywhere in application:
Call Instance2.CopyFrom ( Instance1 )

It's not real "object oriented", but if you add variable
to class, you should modify function in that class only,
not in all instances of the class.

--
Ifo, tangram software, Slovakia

RainerE
Germany
Posts: 2212
Joined: 27 Apr 2021, 12:40
Location: Germany

Re: Fast Copy of instance var's of functional class

Post by RainerE » 24 Jan 2005, 12:26

 Posted by:  Rainer Ebert 

That's the same we do.
Rainer

We are working with Centura 8 years and didn't
found some easy way. We use little workaround -
we create function CopyFrom in functional class
like this:

Functional class: XXX
...
Function: CopyFrom
Description:
Returns
Parameters
class XXX: Src
Static Variables
Local variables
Actions
Set var1 = Src.var1
Set var2 = Src.var2
...

Then, anywhere in application:
Call Instance2.CopyFrom ( Instance1 )

It's not real "object oriented", but if you add variable
to class, you should modify function in that class only,
not in all instances of the class.

--
Ifo, tangram software, Slovakia

StefanM
Germany
Posts: 679
Joined: 10 Aug 2018, 15:57
Location: Bavaria

Re: Fast Copy of instance var's of functional class

Post by StefanM » 24 Jan 2005, 12:57

 Posted by:  Stefan Misch 

Ifo,

thanks, that's exactly what I'm doing right now.
I just wondered wether there are any undocumented functions or some hack to
do a raw in-memory copy.

Stefan

We are working with Centura 8 years and didn't
found some easy way. We use little workaround -
we create function CopyFrom in functional class
like this:

Functional class: XXX
...
Function: CopyFrom
Description:
Returns
Parameters
class XXX: Src
Static Variables
Local variables
Actions
Set var1 = Src.var1
Set var2 = Src.var2
...

Then, anywhere in application:
Call Instance2.CopyFrom ( Instance1 )

It's not real "object oriented", but if you add variable
to class, you should modify function in that class only,
not in all instances of the class.

--
Ifo, tangram software, Slovakia

cschubert
Germany
Posts: 867
Joined: 23 May 2018, 11:26
Location: Germany

Re: Fast Copy of instance var's of functional class

Post by cschubert » 24 Jan 2005, 13:18

 Posted by:  Christian Schubert 

IIRC "XSalUdv" contained in XSal should do exactly what you want...

HTH

Christian Schubert

michael
Germany
Posts: 280
Joined: 07 Jun 2018, 15:13
Location: Stuttgart, GER

Re: Fast Copy of instance var's of functional class

Post by michael » 24 Jan 2005, 14:04

 Posted by:  Michael Hummel 

hi stefan,

this oop - enhancements were discussed at a developer conference years ago
( f-opio or d-wiesbaden i think ...). there where many votings for these
features.
nothing happens .

Now, with td 2005 we have "Improved Find & Replace for higher developer
productivity" (Kristie Wells, 2005-Jan-05)
i am very very very happy about these cool new things.

michael

luca.pivato
United States of America
Posts: 611
Joined: 10 May 2017, 23:43
Location: USA

Re: Fast Copy of instance var's of functional class

Post by luca.pivato » 24 Jan 2005, 15:29

 Posted by:  Gianluca Pivato 

That's correct: http://www.iceteagroup.com/Help/XSal2/index.html

--Gianluca

Acclaro
Germany
Posts: 166
Joined: 16 Mar 2017, 08:13
Location: Hannover, Deutschland

Re: Fast Copy of instance var's of functional class

Post by Acclaro » 25 Jan 2005, 20:40

 Posted by:  Rossmayer 

what about that?

You do not have the required permissions to view the files attached to this post.

Catalin Enache

Re: Fast Copy of instance var's of functional class

Post by Catalin Enache » 25 Jan 2005, 21:31

 Posted by:  Catalin Enache 

It doesn't work.
Just add
Set Copy[0].Number = 99
after the call to cfktCopycFC()
and see what happens.

Catalin

RainerE
Germany
Posts: 2212
Joined: 27 Apr 2021, 12:40
Location: Germany

Re: Fast Copy of instance var's of functional class

Post by RainerE » 25 Jan 2005, 21:52

 Posted by:  Rainer Ebert 

I've made the same test.
It does not work because the code copies the pointer to the functional class
object, not the object itsself.
Now you have 3 array elements pointing to the same object. If you change it,
all pointers point to the changed object. :-(

Rainer

Return to “forum.sqlwindows”

Who is online

Users browsing this forum: [Ccbot] and 0 guests