1. Sathishkumar S
  2. PowerBuilder
  3. Tuesday, 4 June 2024 13:44 PM UTC

HI All,

I need help. I have a structure, `str_patient`, with different data types such as long, string, boolean, datetime, datawindow, and userobject.

From one datawindow, I am loading the local structure with all required parameters and the datawindow, like this: `lstr_patient.d_appt = dw_data`.

I am then passing the structure to another user object and receiving it as instance structure `istr_patient`, while keeping the object open.

When I repeat the process a second time, the datawindow in the structure from the first instance gets overwritten by the second instance.
But I can see string, long, Boolean all are okay with 2 different instance, only dw got overwritten from second to first instance.

Can you help me understand why this is happening and how to fix it?

David Peace Accepted Answer Pending Moderation
  1. Wednesday, 5 June 2024 15:41 PM UTC
  2. PowerBuilder
  3. # 1

I think that the DW is passed as a reference (i.e. pointer to the original DW), this is so that you can manipulate the data etc on the original DW control. It would be good to understand your business process and why you need to duplicate the DW in the receiving object.

If you duplicate the data and rows in the DW then surely there is a potential for duplicate inserts/updates if you update both instances of the DW?

You could always pass the DW by reference and then decare a new DW on the receiving DW and copy the rows to the new DW control. That might be quicker than the FullSate method.

Still, some good advice given here.

Comment
  1. Sathishkumar S
  2. Wednesday, 5 June 2024 17:01 PM UTC
Hi David,

Thank you, I will try your suggestion.

In business process (from the date wise dashboard list in one user object, opening a single entry in another user object (passing the dws through structure) and do all updates, to make it simple for the user allow them to do the changes here instead of going back to the dashboard )

Thanks & Regards,

Sathishkumar S.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Tuesday, 4 June 2024 15:21 PM UTC
  2. PowerBuilder
  3. # 2

Hi, Sathishkumar -

A confusing scenario, and I'm not sure I completely understand it in detail. However, would you please clarify: Is the str_patient structure being passed to the user object by value or by reference?

Also, I don't know if you are aware, but standard data types (strings, longs, etc.) and objects (DataWindow controls (DWC's), user objects, for example) are managed quite differently in structures. When you assign a string variable, for example, to a string member of a structure, the value is copied. When you assign an object such as a DWC to a structure member, a reference to the DWC is placed in the structure... not a copy of the object.

Perhaps this will help you see what is happening "under the covers", so to speak.

Best regards, John

Comment
  1. Sathishkumar S
  2. Tuesday, 4 June 2024 17:13 PM UTC
Hi John,



str_patient structure being passed to the user object by value



I was not aware about the standard data types and objects are managed differently in structure, now I am getting a better understanding about it.

So the dwc to structure is always reference only and it is going to be same in all the instance of the structure?

Is there anyway to handle the diff instance of the structure to differentiate from one another.



Thanks & Regards,

Sathishkumar S.

  1. Helpful
  1. John Fauss
  2. Wednesday, 5 June 2024 00:57 AM UTC
Unfortunately, without a better understanding of what you are attempting to accomplish and having the existing objects and code in front of me, I cannot recommend any alternative coding strategies. Even if I had that information available, I'd be hesitant to offer any advice of this sort, as I would be providing you with consulting services. That's not what the Q&A forum is for, and I have no desire or plans to provide consulting services to anyone.
  1. Helpful
  1. Sathishkumar S
  2. Wednesday, 5 June 2024 14:42 PM UTC
Hi John,

Thank you, I can understand it is a Q&A forum. I was trying to understand the mechanism of passing objects through the structure.

Thanks & Regards,

Sathishkumar S.
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Tuesday, 4 June 2024 15:12 PM UTC
  2. PowerBuilder
  3. # 3

Pass your dw using GetFullState and on the receiving site use SetFullState.

Comment
  1. Sathishkumar S
  2. Tuesday, 4 June 2024 17:09 PM UTC
Hi Miguel,



I have tried using Getfullstate to get the dw as blob and add one more variable as blob in structure (str_patient) and assign dwblob to structure blob

then passing it as value to another user object and receiving the structure and try to create dw from the blob using SetFullState, trying to cross check it is working or not.

seems working fine in first glance.

feeling it takes little more time like 2 - 3 secs more then usual when using getfullstate and setfullstate.

Let run it fully to understand.



Thank you.



Regards,

Sathishkumar S



  1. Helpful
  1. Sathishkumar S
  2. Wednesday, 5 June 2024 14:43 PM UTC
Hi Miguel,

Thank you, I have used GetFullState and SetFullState, and it is working well.

Thanks & Regards,

Sathishkumar S.
  1. Helpful
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.