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

use a datastore as a datawindow

945 views
Skip to first unread message

George

unread,
Nov 16, 2004, 4:18:02 AM11/16/04
to
Hi every one !

I've got many object and functions which all use datawindow object type as
parameters (print, pdf generating, others, ...)

I'd like to use thoses object with datastore (don't need visual 'cause
datawindows are loaded by code and don't have to be view). Thus, datastore
can be created with the create function.

My problem is that datastore can't be passed as argument to a function when
a datawindow is expected. Why is there no commune ancestor ?

Is there a way to create datawindow object by code ?


kaaposc

unread,
Nov 16, 2004, 6:37:45 AM11/16/04
to
George wrote:
> Is there a way to create datawindow object by code ?

try it with dw.Create (dwsyntax)..

George

unread,
Nov 16, 2004, 9:43:53 AM11/16/04
to

"kaaposc" <kaa...@one.lv> a écrit dans le message de
news:4199e689@forums-1-dub...

> George wrote:
> > Is there a way to create datawindow object by code ?
>
> try it with dw.Create (dwsyntax)..

Ok but how deal with a DW name ?
With a DS, I use to code:

ds_fils = CREATE datastore
ds_son.DataObject = ls_report_name


Boris Gasin

unread,
Nov 16, 2004, 10:10:07 AM11/16/04
to
On 16 Nov 2004 06:43:53 -0800, "George"
<george...@yahoo-nospam.fr> wrote:


I have a feeling you are not asking the question George has answered.
If you elaborate a little on your requirement it may be easier to give
you the right answer.

My guess is... You have a datawindow object defined and want to
create a control dynamically. If that is the case you can use the
OpenUserObject() function.

George

unread,
Nov 16, 2004, 10:28:01 AM11/16/04
to

"Boris Gasin" <NOSPAM...@dynamictechgroup.com> a écrit dans le message
de news:gq5kp05k0o5ocs50b...@4ax.com...

In fact, I'd like to use a datawindow object, as well I use to with a
datastore, without having to drop a non-visible datawindow control.


Paul Horan[TeamSybase]

unread,
Nov 16, 2004, 10:42:21 AM11/16/04
to
"George" <george...@yahoo-nospam.fr> wrote in message news:4199c5ca@forums-1-dub...

Change the function definitions to take a PowerObject instead, then cast the passed argument into either datawindow or
datastore.

--
Paul Horan[TeamSybase]


JA

unread,
Nov 16, 2004, 1:19:46 PM11/16/04
to
Following the suggestions, I'm making a function where one of its parameter
is of type "powerobject".

But, depending if the function receives a datawindow or a datastore, I
instance a variable, as I show below:

choose case apo_source.typeof()
case DataWindow!
u_dw _source
_source = create u_dw
case DataStore!
n_ds _source
_source = create n_ds
case else
return FAILURE
end choose

But, when the powerbuilder's compiler find the second declaration ( n_ds
_source ) sends the next messages:
"Error C0081: Duplicate variable: _source"

Is there a way to do something like that ?

Thanks.


"Paul Horan[TeamSybase]" <paulhATvcisolutionsDOTcom> escribió en el mensaje
news:419a1fdd$1@forums-1-dub...

philipsalgannik

unread,
Nov 16, 2004, 1:53:07 PM11/16/04
to

Avis Crane

unread,
Nov 16, 2004, 3:16:15 PM11/16/04
to
I might be totally off the wall here, but you have an extra space in
"u_dw_source" and "n_ds_source" - see arrows below. The error message does say
"Error C0081: Duplicate variable: _source". Could that be the problem?


JA <jaimea...@hotmail.com> wrote:
[snip]


>choose case apo_source.typeof()
> case DataWindow!

> u_dw _source <---------------------


> _source = create u_dw
> case DataStore!

> n_ds _source <---------------------


> _source = create n_ds
> case else
> return FAILURE
>end choose
>
>But, when the powerbuilder's compiler find the second declaration ( n_ds
>_source ) sends the next messages:
>"Error C0081: Duplicate variable: _source"

[snip]

Paul Horan[TeamSybase]

unread,
Nov 16, 2004, 4:06:47 PM11/16/04
to
"Avis Crane" <raraavisATrocketmailDOTcom> wrote in message news:419a600f$1@forums-1-dub...

>I might be totally off the wall here, but you have an extra space in
> "u_dw_source" and "n_ds_source" - see arrows below. The error message does say
> "Error C0081: Duplicate variable: _source". Could that be the problem?

Yes, you're off the wall... <G>

That line of code is a variable declaration. It consists of a type (u_dw / n_ds) and a local variable name (_source).
Some people have adopted the crazy standard of naming their variables with a leading underscore. I find that personally
objectionable, but to each, his own...
The error message is telling this person that he has declared a local variable twice - with different classtypes.

Paul Horan[TeamSybase]

Paul Horan[TeamSybase]

unread,
Nov 16, 2004, 4:12:06 PM11/16/04
to
"JA" <jaimea...@hotmail.com> wrote in message news:419a44c2$1@forums-1-dub...

> Following the suggestions, I'm making a function where one of its parameter
> is of type "powerobject".
>
> But, depending if the function receives a datawindow or a datastore, I
> instance a variable, as I show below:
>
> choose case apo_source.typeof()
> case DataWindow!
> u_dw _source
> _source = create u_dw
> case DataStore!
> n_ds _source
> _source = create n_ds
> case else
> return FAILURE
> end choose
>
> But, when the powerbuilder's compiler find the second declaration ( n_ds
> _source ) sends the next messages:
> "Error C0081: Duplicate variable: _source"
>
> Is there a way to do something like that ?
>
> Thanks.
>
>

No - try it this way:
lDW u_dw
lDS n_ds

Choose case apo_source.typeof()
case DataWindow!
lDW = apo_source
lDW.Print()

case DataStore!

lDS = apo_source
lDS.Print()

case else
return FAILURE

end choose


Or, even easier:

Choose case apo_source.typeof()
case DataWindow!, DataStore!

apo_source.DYNAMIC print() // or whatever the function name is...
return SUCCESS

case else
return FAILURE

end choose


--
Paul Horan[TeamSybase]


JA

unread,
Nov 16, 2004, 6:44:49 PM11/16/04
to
Paul, in this case, can you change the data type in execute time, from
"powerobject" to "datawindow" (or "datastore").
What you mean when you say "cast the passed argument into either datawindow
or datastore" ?

The way using "dynamic" works ok when you have cases like
apo_source.DYNAMIC describe( "datawindow.column.count" ),

but, not for:
apo_source.DYNAMIC inv_base.of_getitemany( ll_row, ll_col ) or
apo_source.inv_base.DYNAMIC of_getitemany( ll_row, ll_col )


Thanks.

"Paul Horan[TeamSybase]" <paulhATvcisolutionsDOTcom> escribió en el mensaje

news:419a6d26$1@forums-1-dub...

Paul Horan[TeamSybase]

unread,
Nov 17, 2004, 12:15:24 AM11/17/04
to
in line...

--
Paul Horan[TeamSybase]

"JA" <jaimea...@hotmail.com> wrote in message news:419a90ed@forums-2-dub...


> Paul, in this case, can you change the data type in execute time, from
> "powerobject" to "datawindow" (or "datastore").
> What you mean when you say "cast the passed argument into either datawindow
> or datastore" ?

This assignment statement casts the ancestor PowerObject class into the descendent Datawindow class:
lDW = apo_source


>
> The way using "dynamic" works ok when you have cases like
> apo_source.DYNAMIC describe( "datawindow.column.count" ),
>
> but, not for:
> apo_source.DYNAMIC inv_base.of_getitemany( ll_row, ll_col ) or
> apo_source.inv_base.DYNAMIC of_getitemany( ll_row, ll_col )

Of course it works. You just missed a step...

u_dw l_DW
inv_base l_NVO

Choose case apo_source.typeOf()
Case datawindow!
u_dw = apo_source // cast into a u_dw
l_nvo = u_dw.inv_base // get a reference to the inv_base instance var
l_nvo.of_getItemAny( blah, blah )

End Choose


ALP

unread,
Nov 17, 2004, 3:49:42 AM11/17/04
to
Try:

.. function_name(powerobject apo)
datastore lds
datawindow ldw
boolean isOriginalDatastore

choose case apo.TypeOf()
case datawindow!
ldw=apo
lds=Create datastore
lds.dataobject=ldw.dataobject // Or create from syntax of datawindow
ldw.ShareData(lds)
isOriginalDatastore=TRUE
case datastore
lds=apo
isOriginalDatastore=FALSE
case else
// ERROR CODE
end choose

// Work on lds
...
...

// Exit
if isOriginalDatastore then
destroy lds
end if

return

"George" <george...@yahoo-nospam.fr> a écrit dans le message de news:
4199c5ca@forums-1-dub...

Avis Crane

unread,
Nov 17, 2004, 10:48:50 AM11/17/04
to
Ahah! You've confirmed what I always suspected. :) Or, at least, don't read code
in the late afternoon. :-) I had never seen variable names with a leading
underscore before - confusing!
0 new messages