0
Votes
Undo
  1. marco gaspar
  2. PowerBuilder
  3. Friday, 5 July 2024 12:58 PM UTC

Good morning!
Is it possible to create a datawindow at runtime and pass it as a parameter to another function or event?

Thanks!

Who is viewing this page
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Monday, 8 July 2024 09:43 AM UTC
  2. PowerBuilder
  3. # 1

In most cases you'll want to use a Datastore object instead. If you absolutely must create a DW reference at runtime you can open an invisible window and get a valid DW like this:

window wdummy
datawindow dw
Open(wdummy)
wdummy.hide()
dw = create datawindow
wdummy.openuserobject( dw )
dw.dataobject = 'd_whatever'
dw.settransobject( ... )
dw.retrieve(...)

// Do stuff

wdummy.closeuserobject( dw )
close( wdummy )

 

Comment
  1. marco gaspar
  2. Monday, 8 July 2024 12:17 PM UTC
Good morning Benjamin Gaesslein!

Thank you very much, his solution worked.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 5 July 2024 14:27 PM UTC
  2. PowerBuilder
  3. # 2

Hi Marco;

   Yes & No...

  • No as the DWO is a "custom" object that cannot exist outside a "container" class
  • Yes if you have the DWO embedded within a DW Contol or DataStore. then the DC/DS object's pointer can be passed as an object pointer to an event or function.

HTH

Regards .. Chris

Comment
  1. marco gaspar
  2. Friday, 5 July 2024 17:14 PM UTC
Do you have an example?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Friday, 5 July 2024 18:18 PM UTC
DataStore lo_ds

lo_ds = Create DataStore .// Instantiate DS

lo_ds.data object = "dw_object" // Load DW object

// What ever processing ...

<Object>.<UserEvent> ( lo_ds ) // Pass DS + DWO to another object's event
  1. Helpful
  1. marco gaspar
  2. Friday, 5 July 2024 18:53 PM UTC
Thanks Chris!
  1. Helpful 1
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.