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 ?
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
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.
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.
Change the function definitions to take a PowerObject instead, then cast the passed argument into either datawindow or
datastore.
--
Paul Horan[TeamSybase]
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...
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]
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]
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]
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]
"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
.. 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...