Mailing List Archive

solved: win32com function<->propterty problem
On 30 Apr 1999 04:26:34 GMT, Bernhard Reiter <bernhard@alpha1.csd.uwm.edu> wrote:

Thanks to Mark H. the problem dissolved:

Using the makepy script and looking in the source it generated,
I found the right function:

SetValueAt(1,1,"new Value")

FYI
Bernhard
(Oh Mark, it just comes into my mind: What if SetValueAt already
existed as OLE method? Will makepy then choose a different name?)

. My OLE object an instance of ISpssDataCells
. should have an array as property. From the SPSS documentation:
.
. ValueAt Property
. Returns or sets the value of the current data cell or row/column label.
.
. Syntax
. object.ValueAt (row,column) [=value]
.
. Settings
. row Row index (Long)
. column Column index (Long)
. value Variant (String or Binary)
.
.
. Python win32com provides that as a function.
. And I can perfectly get the values like
. value=object.ValueAt(1,1)
. but setting ist a problem:
.
. >>> d
. <win32com.gen_py.SPSS Pivot Table Type Library.ISpssDataCells>
. >>> d.ValueAt
. <method ISpssDataCells.ValueAt of ISpssDataCells instance at 1199f00>
. >>> d.ValueAt(1,1)
. >>> d.ValueAt(1,1)=123
. Error pulling apart exceptionTraceback (innermost last):
. File "C:\Python\Pythonwin\pywin\framework\interact.py", line 345, in keyhandler_enter
. message, (filename, lineno, offset, text) = exc_value
. ValueError: unpack sequence of wrong size
. SyntaxError: can't assign to function call
.
.
. The Python Com Browser shows me, that there are two entries in
. the Registered Spss Pivot Table Type Library, ISpssDataCells as
. function:
. ValueAt - Function
. Dispatch ID=26
. Named Params ='row,col'
. Return Type ='Variant'
. Argument = 'Integer 4 (Flags=1)'
. Argument = 'Integer 4(Flags=1)'
. Function Kind ='Dispatch'
. Invoke Kind = 'Property Get'
. Number Optimal Params=0
. ValueAt - Function
. Dispatch ID=26
. Named Params ='row,col'
. Return Type ='Void'
. Argument = 'Integer 4 (Flags=1)'
. Argument = 'Integer 4(Flags=1)'
. Argument = 'Variant (Flags=1)'
. Function Kind ='Dispatch'
. Invoke Kind = 'Property Put'
. Number Optimal Params=0
.
. Okay, python seems to know about both possibilities, but how do
. I use them?
solved: win32com function<->propterty problem [ In reply to ]
Bernhard Reiter wrote in message ...

>(Oh Mark, it just comes into my mind: What if SetValueAt already
>existed as OLE method? Will makepy then choose a different name?)

Its not too smart. It checks that an existing function of the same name
exists, and if so, appends a "Set" - hence you got "SetValueAt".

So the name you got was caused by a name clash, but if there was already a
SetValueAt, it would not detect that.

Glad you got it going!

Mark.
solved: win32com function<->propterty problem [ In reply to ]
On Mon, 3 May 1999 09:02:57 +1000, Mark Hammond <MHammond@skippinet.com.au> wrote:
>Bernhard Reiter wrote in message ...
>
>>(Oh Mark, it just comes into my mind: What if SetValueAt already
>>existed as OLE method? Will makepy then choose a different name?)
>
>Its not too smart. It checks that an existing function of the same name
>exists, and if so, appends a "Set" - hence you got "SetValueAt".

Well you got another idem on the DOTO list then. ;-)
Check for name clashes. Shouldn't be too hard.

Just schedule all items which should get new names in a
list and create the new names at the end of the makepy run.
Then resolve the furhter clashes...

>So the name you got was caused by a name clash, but if there was already a
>SetValueAt, it would not detect that.

would be nice, if makepy spits some messages about that
names, while running.

Thanks again.
Bernhard