1. Peter Hitzke
  2. PowerBuilder
  3. Tuesday, 27 October 2020 11:23 AM UTC

Hello there,

is there any way to clone a userobject with al it's references.

 

I have a userobejct (uo_userobject_1) with 2 datastores and many proterties.

 

If I want to clone this obejct like 

 

uo_userobject_2 = uo_userobject_1

 

it only creates a referece to the existing dw's of the uo_userobject_1.

 

Is there any Option to clone the uo_userbject_1 to uo_userobject_2 like uo_userobject_2.copy(uo_userobejct_1) ?

Rowscopy wont help in my Problem.

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 28 October 2020 18:39 PM UTC
  2. PowerBuilder
  3. # 1

Hi Peter;

  This might make a nice enhancement suggestion ...

uo_userobject_2 = Create From uo_userobject_1

Regards ... Chris

Comment
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Tuesday, 27 October 2020 12:12 PM UTC
  2. PowerBuilder
  3. # 2

It sounds like you're talking about cloning at runtime, because in the IDE you can just do SaveAs.  Not sure why you'd want to do it in code instead of creating another instance.  This is one of those cases where it's best to supply as much info as possible about what it is that you are trying to do and why, because there may be a better way to do it.  Is it a visual userobject?  If so, take a look at OpenUserObject function.

Comment
There are no comments made yet.
René Ullrich Accepted Answer Pending Moderation
  1. Tuesday, 27 October 2020 11:52 AM UTC
  2. PowerBuilder
  3. # 3

Hello Peter,

You have to write your own copy function that copys the data in the case you need.

It is not a trivial problem:

You have to decide how to handle with objects that are referenced by the object you want to copy (in your case the two datastores). Do you want to copy the reference of the two datastores or do you want to copy the two datastores too? 

If you want to copy the datastores there are also different options how to copy the data, itemstatus etc. (e.g. RowsCopy vs. GetfullState/SetFullstate).

All referenced objects may also have references to other objects. And so on.

HTH,

René

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.