>I have created a datawindow service. This is a non-visual user-object,
>inherited from n_cst_dwsrv (the PFC's base-class non-visual for
>datawindow services.) I happened to notice something about the
>of_SetRequestor() function that has me mildly perplexed.
>of_SetRequestor is a function in n_cst_dwsrv which is called by a
>datawindow control when it "turns on" a particular service. The
>function essentially gives the service nvo a pointer back to the
>datawindow control that "owns" it. The "prototype" looks basically like
>this:
>
>[None] of_SetRequestor ( u_dw adw_Requestor)
>
>So here is my question: why is it that this function's declaration has
>a datawindow control (u_dw) being passed to it by value, instead of by
>reference? Does passing a datawindow by value not give you a second,
>separate "instance" of a datawindow (or, in this case, a u_dw), rather
>than just a pointer to one? Does passing a datawindow by value behave
>differently than passing simple data types by value?
>
>Initially, I thought this may have been an oversight - that it really
>should be passed by reference. Before I go clobbering any function
>declarations, however, I figured I should do some checking!
>
>Thanks in advance,
>--
>Rick Manocchi
>Certified PowerBuilder Developer - Associate
>(Mano...@OlyWa.Net)
>
>
When you pass a datawindow as an argument, you can alter attributes
for that datawindow via modify. AFAIK it does not make a second copy
of the dw because if you change anything it is reflected in the dw
that you passed. I guess that does sound like passing by reference
for most variables. My point is that with a dw argument, AFAIK it
doesn't matter how you pass the argument. I'm sure if anyone else has
comments about this they will jump in.
Larry Cermak [Team Powersoft]
Branick Consulting,Inc.
lce...@flash.net
The simplest way to explain it is that when passing anything descended from
powerobject as an argument, you're actually passing a POINTER to that
object, not the entire object itself. So passing the pointer by value is
no big deal, and is exactly what you want 99 pecent of the time. See
Brez's explanation for a more complete discussion of why you might want to
pass a powerobject by reference.