Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems with PowerObjectParm in CloseWithReturn()

670 views
Skip to first unread message

Dave Ringot

unread,
Jun 30, 2004, 2:23:26 PM6/30/04
to
I'm using PB 8.0.3. I'm trying to pass a structure from a window to a
function using the PowerObjectParm. I declared identical strucures in the
window and the function that opens the window. I open the window from
within the function. The window uses CloseWithReturn() to return its
structure to the function. Then in the function I attempt to set the value
of the local structure to that of the PowerObjectParm like this:

lstr_rates = Message.PowerObjectParm

At runtime, this statement causes an application error. I don't use
structures very often, so maybe I'm doing something wrong here. Any
suggestions?

TIA - Dave


Roy Kiesler [TeamSybase]

unread,
Jun 30, 2004, 2:53:31 PM6/30/04
to
Can you provide more script? Specifically, the call to CloseWithReturn()?

--
Roy

Dave Ringot

unread,
Jun 30, 2004, 3:18:24 PM6/30/04
to
Here's the definition of the structure in the window:

str_exch_rates
decimal exch_rate_q1
decimal exch_rate_q2
decimal exch_rate_q3
decimal exch_rate_q4

Here's the code executed when the window closes:

str_exch_rates lstr_rates
lstr_rates.exch_rate_q1 = dw_criteria.GetItemDecimal(1, "exch_rate_q1")
lstr_rates.exch_rate_q2 = dw_criteria.GetItemDecimal(1, "exch_rate_q2")
lstr_rates.exch_rate_q3 = dw_criteria.GetItemDecimal(1, "exch_rate_q3")
lstr_rates.exch_rate_q4 = dw_criteria.GetItemDecimal(1, "exch_rate_q4")
CloseWithReturn(Parent, lstr_rates)

The function contains an identical local structure. Here's the code in the
function:str_exch_rates lstr_rates

str_exch_rates lstr_rates
Open(w_report_criteria)
lstr_rates = Message.PowerObjectParm

I checked to see if PowerObjectParm is null, but it's not. I can't figure
out what I'm doing wrong.

Dave

"Roy Kiesler [TeamSybase]" <SPAM_FREE_...@teamsybase.com> wrote in
message news:40e30c2b$1@forums-1-dub...

Roy Kiesler [TeamSybase]

unread,
Jun 30, 2004, 3:41:21 PM6/30/04
to
> Here's the code executed when the window closes:

Is this code running in the window's close event by chance?

Dave Ringot

unread,
Jun 30, 2004, 4:24:24 PM6/30/04
to
No. It's run from a button click. The Close event doesn't contain any
code.

"Roy Kiesler [TeamSybase]" <SPAM_FREE_...@teamsybase.com> wrote in

message news:40e31761$1@forums-1-dub...

Jerry Siegel

unread,
Jun 30, 2004, 4:35:30 PM6/30/04
to
Referring to a variable in an object that has gone out of scope or been
destroyed will bomb every time. Try making the structure an instance
variable rather than a local one.

"Dave Ringot" <da...@bwc.com> wrote in message
news:40e32178$1@forums-1-dub...

Ken Balakrishnan

unread,
Jun 30, 2004, 4:49:38 PM6/30/04
to
Maybe a silly question, but are you sure the window you're opening is a
Response window?

Ken

"Dave Ringot" <da...@bwc.com> wrote in message
news:40e32178$1@forums-1-dub...

Dave Ringot

unread,
Jun 30, 2004, 5:01:53 PM6/30/04
to
Ken: Yes, I doublechecked that it is a Response window.

Jerry: I tried creating an instance variable but when I do, I get the
following warning:

Warning C0190: Instance variables of local structure type (str_exch_rates)
will be implicitly private in the next release.

It then seems to ignore the instance variable because as soon as I leave the
instance variable list and come back, the instance variable I tried to
create is gone. Did you mean that the structure itself, str_exch_rates,
needs to be created as an instance variable? I'm not really clear on how I
would go about doing this. Am I not understanding you correctly?

Dave


"Jerry Siegel" <jer...@data-sci.com.nospam> wrote in message
news:40e324b6$1@forums-2-dub...

Ken Balakrishnan

unread,
Jun 30, 2004, 5:13:56 PM6/30/04
to
Aha -- you must have one structure defined on the window and another one
either in the function or as a global structure. Since you want to share
the structure between objects, you should have just a single global
structure str_exch_rates (create it by going to File->New..., select the PB
Object tab and the Structure icon), and delete the definition that's local
to the window (and the one that's local to the function, if that's what it's
using).

Ken

"Dave Ringot" <da...@bwc.com> wrote in message

news:40e32a41$1@forums-1-dub...

Dave Ringot

unread,
Jun 30, 2004, 5:29:24 PM6/30/04
to
Is using a global structure the only way to do this? From reading the help
on CloseWithReturn(), I got the impression that I could pass local
structures from a window to a function using Message.PowerObjectParm. I
took this approach because I was starting to get concerned about the number
of global variables in my application.

If using a global structure is the only way, I have another question. Is
there any advantage to creating a global structure that contains 4 decimal
vars, instead of just creating 4 global decimal vars?

Dave

"Ken Balakrishnan" <kNOe...@cps92.com> wrote in message
news:40e32d14$1@forums-1-dub...

Ken Balakrishnan

unread,
Jun 30, 2004, 5:37:35 PM6/30/04
to
After posting, I realized that I wasn't very clear. You can pass a local
structure *variable* just fine, but the variables on either end have to be
of the same type. As it is, you're trying to assign a variable of type
window1.str_exch_rates to a variable of either function1.str_exch_rates or
str_exch_rates. You have to get rid of the local type definition in your
window (in the Window painter, go to View->Structure) and make sure that the
variables refer to the definition that you see (or will see) in the PBL
itself.

Hopefully that makes more sense -- I'm having a hard time putting this into
words.

Ken


"Dave Ringot" <da...@bwc.com> wrote in message

news:40e330b4$1@forums-1-dub...

Dave Ringot

unread,
Jun 30, 2004, 7:07:57 PM6/30/04
to
I think I'm still a little confused. I don't quite understand what you
meant when you said the following:

You have to get rid of the local type definition in your window (in the
Window painter, go to View->Structure) and make sure that the variables
refer to the definition that you see (or will see) in the PBL itself.

When you said that I need to get rid of the local type definition in my
window, do you mean that I need to delete the structure altogether? If so,
where do I declare the structure that I will be returning in my call to
CloseWithReturn()? Sorry for all the questions about this, but I don't use
structures very often.

Just so we're clear on this, here's what I currently have setup: In my
window painter, and my function painter, I have the structure view
displayed. I have identical structures declared called 'str_exch_rates'.
Each one contains 4 variables, all of type decimal. In both the window and
function objects, I declare a local variable 'lstr_rates' of type
'str_exch_rates'. Just before I call CloseWithReturn, I assign values to
the variables in the local structure lstr_rates. Does this help you?

Dave

"Ken Balakrishnan" <kNOe...@cps92.com> wrote in message

news:40e3329f$1@forums-1-dub...

Andrew Giulinn

unread,
Jun 30, 2004, 8:40:53 PM6/30/04
to
Hi Dave

I think that your problem is:

<snip> "I have identical structures declared called 'str_exch_rates'"
</snip>

I think the point is that both the window and the function have to see the
SAME declaration of 'str_exch_rates'. In your situation, the window and the
function are each seeing a different, but identical, declaration.

One way to do this would be to use a "global" structure (which you are
trying to avoid - we never use them).

Rather than creating a "global" structure, create a PB object which is a
structure. Do this via File -> New -> PB Object tab -> Structure, which
opens the Structure Painter and you can save the structure as a PB object,
eg 's_exch_rates'. Then remove both your declarations of 'str_exch_rates'
and have your window and your function refer to 's_exch_rates' instead.
That way, they are both referring to the same declaration of the structure
involved.

I think that this is what Ken has been getting at.

There might be other ways to do this, but this is the technique that we have
used, without problem.

Cheers

--
Andrew Giulinn
Senior Analyst/Programmer
Integrated Aviation Software Pty Ltd

"Dave Ringot" <da...@bwc.com> wrote in message

news:40e34873$1@forums-2-dub...


> I think I'm still a little confused. I don't quite understand what you
> meant when you said the following:
>
> You have to get rid of the local type definition in your window (in the
> Window painter, go to View->Structure) and make sure that the variables
> refer to the definition that you see (or will see) in the PBL itself.
>
> When you said that I need to get rid of the local type definition in my
> window, do you mean that I need to delete the structure altogether? If
so,
> where do I declare the structure that I will be returning in my call to
> CloseWithReturn()? Sorry for all the questions about this, but I don't
use
> structures very often.
>
> Just so we're clear on this, here's what I currently have setup: In my
> window painter, and my function painter, I have the structure view
> displayed. I have identical structures declared called 'str_exch_rates'.
> Each one contains 4 variables, all of type decimal. In both the window
and
> function objects, I declare a local variable 'lstr_rates' of type
> 'str_exch_rates'. Just before I call CloseWithReturn, I assign values to
> the variables in the local structure lstr_rates. Does this help you?
>
> Dave

snip...


Jerry Siegel

unread,
Jul 1, 2004, 10:45:36 AM7/1/04
to
The *definition* of the structure class would be global - in a PBL in your
application and therefore available to any object in the application. The
*instance* of the structure would be declared as an instance variable of the
window, and again in the function. That way both declarations are of the
same class and they match.

"Andrew Giulinn" <NO.osc...@dsa.com.au> wrote in message
news:40e35d95@forums-1-dub...

Dave Ringot

unread,
Jul 1, 2004, 12:16:48 PM7/1/04
to
Okay, I think I finally understand it now. I created the structure as a pb
object and got rid of the local definitions. No more application errors.

Thanks for all the help everyone,

Dave

"Jerry Siegel" <jer...@data-sci.com.nospam> wrote in message

news:40e42436@forums-2-dub...

cdd...@gmail.com

unread,
Oct 22, 2015, 1:07:57 AM10/22/15
to
what does parent mean in closewithreturn(parent,1)
0 new messages