1. kevin kevin rowe
  2. PowerBuilder
  3. Wednesday, 6 September 2023 12:43 PM UTC

In my one of my libraries I have a datawindow dw_example.

This datawindow is in use in other places and definitely works.

I have a function that requires a datawindow as a parameter, because it is generally called from a report window.

In this instance it is not. I need to create a datawindow on the fly from the definition of dw_example, and add a row to it,

then pass this to the function.

 

I have tried 

dw_1 = create datawindow
dw_1.dataobject = "dw_example"
dw_1.SetTransObject (SQLCA)
liret = dw_1.Retrieve()

This does not work.

 

I can create a datastore dynamically and this does work

ds_1 = create datastore
ds_1.dataobject = "dw_example"
ds_1.SetTransObject (SQLCA)
liret = ds_1.Retrieve()

Is it possible to create the datawindow directly or export the definition from the datastore to the datawindow?

dumping to a blob and importing crashed the app

You can dump the datastore to a resultset, but although the manual says there is a method createfrom (resultset) for datawindows

the compiler flags this as an unknown function name.

I have had a lot of problems with this crashing my app. Many of which I suspect were to do with a watch I had in debug mode that was invalid.

Deleting that allowed me to actually get the datastore version to work where as it was not before.

I've spent a lot of time trying different methods out all of which failed or crashed until I removed the watch.

 

Does anyone have an idea how to achieve the creation of a datawindow variable in local code  from a library definition ready to accept a new row with InsertRow ( 0 ) ?

 

Thank you,

 

Kevin.

 

 

  

Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 6 September 2023 12:48 PM UTC
  2. PowerBuilder
  3. # 1

Hi.

Instead of creating the datawindow try using OpenUserObject (and CloseUserObject when done).

Andreas.

Comment
  1. kevin kevin rowe
  2. Wednesday, 6 September 2023 13:30 PM UTC
Andreas,

The code is in an object function of an NVO. The compiler will not accept

this.openuserobject(

or

openuserobject(

It says unknown function name
  1. Helpful
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 6 September 2023 13:09 PM UTC
  2. PowerBuilder
  3. # 2

Check out the GetFullState() and SetFullState() functions,

regards.

Comment
  1. kevin kevin rowe
  2. Wednesday, 6 September 2023 13:30 PM UTC
Getfullstate and setfullstate are the function using the blob. They crash the app.
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 6 September 2023 14:47 PM UTC
Then there's something you're not doing right.

  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Wednesday, 6 September 2023 14:29 PM UTC
  2. PowerBuilder
  3. # 3

Andreas is correct. you have to use  OpenUserObject if you are creating a visual object.

 

why are you not just using a datastore?

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 6 September 2023 15:46 PM UTC
  2. PowerBuilder
  3. # 4

Hi Kevin;

  Yes, you can create a DW Object dynamically via PowerScript only at runtime via the Modify() command on any DW control or DataStore control, as follows:

DW Control Name>.Modify( &
"create bitmap(band=<Detail, Footer, Header, Header.<group #>, Summary, Trailer.<group #>, Background, Foreground>"  +  &
" pointer='<Arrow!, Cross!, HourGlass!, IBeam!, Icon!, Size!, SizeNESW!, SizeNS!, SizeNWSE!, SizeWE!, UpArrow!, or cursor filename (with path)>' moveable=<0 - False, 1 - True> resizeable=<0 - False, 1 - True> x='<an integer>' y='<an integer>' height='<an integer>' width='<an integer>'" + &
" filename='<filename (with path) containing bmp (i.e., c:\test\fish.bmp)>' invert='<0 - False, 1 - True>' name=<string>"  + &
" tag='<string>')")

HTH

Regards ... Chris

Comment
There are no comments made yet.
Kevin Ridley Accepted Answer Pending Moderation
  1. Wednesday, 6 September 2023 19:16 PM UTC
  2. PowerBuilder
  3. # 5

What exactly are you trying to do that a datastore will not work?  Does it have to be visual?  You can also just have a dw control on a window and assign the DataObject dynamically before you do the SetTransObject and that should do what you need.  We need a little more information on what the "end game" is.

Comment
There are no comments made yet.
Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Thursday, 7 September 2023 04:25 AM UTC
  2. PowerBuilder
  3. # 6

Hi Kevin,

if you really must open a DW instead of a DS (why, though?), you'll have to open a Window to do so. Any window will do and it can be invisible. I'd suggest creating an empty and invisible dummy window just for this purpose. Then something like this should work:

w_dummy lw_dummy
datawindow ldw_dw

Open( lw_dummy)
ldw_dw = create datawindow 
lw_dummy.openuserobject( ldw_dw )
ldw_dw.dataobject = '...'
ldw_dw.SetTransObject (SQLCA)
ldw_dw.retrieve()

 

Comment
  1. Chris Pollach @Appeon
  2. Thursday, 7 September 2023 11:44 AM UTC
Hi Ben;

FYI: You should never use a Create command on a DW control. A) the overhead is unnecessary and B) this can lead to excessive memory use & leaks.

Regards ... Chris
  1. Helpful
  1. Benjamin Gaesslein
  2. Thursday, 7 September 2023 12:33 PM UTC
If you need to add a DW to a window at runtime, you must create it first or you will get a nullpointer exception on trying to execute openuserobject. It's not an ideal solution here but it works.
  1. Helpful
There are no comments made yet.
kevin kevin rowe Accepted Answer Pending Moderation
  1. Thursday, 7 September 2023 15:27 PM UTC
  2. PowerBuilder
  3. # 7

Thanks for the suggestions, guys.

 

In the end I had to add a new parameter of datastore to the structure being passed to the function, as creating a datawindow from where I started was not possible and I could not replace the datawindow parameter with datastore because the function used function references that did not work with datastore.

Adding a new datastore and just 'if' branching the code whenever that type of report was passed to use the datastore instead of the datawindow works. It may not be elegant, but it works.

I would have simply copied the code but it is a very long complex function that emails reports using a number of external connections like outlook OLE and running 3rd party programs with windows process control.

Thanks for your time.

Kevin.

 

 

 

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.