471,091 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,091 software developers and data experts.

Passing COM VB6 strings weirdness

List:

I've a Python COM server that keeps an event logs.

I've been using it from VB6:

logEvent "Message"

The Python side of things looks like:

def logEntry(self, caller = u'Unknown Caller', \
message = u'Unknown Message'):
if self.fileOpen == True:
return self.__Logger(str(caller), str(message))
else:
return -1
The which refers back to the base logger class method:

def __call__(self, caller = 'Unknown Caller', \
message = 'Unknown Message'):
self.logFile.write(ctime(time()) + ', <' + caller \
+ '>, -- ' + message + '\n')
return 0

When I log certain events from VB, I also display a message box for the
user or for me, depending on the specific message.

If I call messageBox BEFORE I invoke logEntry, all is well.

BUT if I invoke logEntry first, the passed string becomes a literal
zero.

Any thoughts on this? I'm not certain why I'm getting the returned
value from this at all, let alone why it's being assigned to the
argument string.

Is my code telling Python to alter the value or is this a VB oddity?

Thanks
Charles


Jul 18 '05 #1
1 1371
drs
"U-CDK_CHARLES\Charles" <"Charles Krug"@cdksystems.com> wrote in message
news:z3******************@nwrdny02.gnilink.net...
List:

I've a Python COM server that keeps an event logs.

I've been using it from VB6:

* * *

When I log certain events from VB, I also display a message box for the
user or for me, depending on the specific message.

If I call messageBox BEFORE I invoke logEntry, all is well.

BUT if I invoke logEntry first, the passed string becomes a literal
zero.

Any thoughts on this? I'm not certain why I'm getting the returned
value from this at all, let alone why it's being assigned to the
argument string.


I don't know if this is the same thing, but I have found that often passing
variables from VB to Python COM servers mucks up the variables on the VB
side. I think I have posted this issue here (probably a few years back),
but I have never gotten a reason why -- i think. Also, I have never really
pinned down exectly what circumstances lead to it. Instead, I have gotten
used to declaring two identicle variables in VB when I need to do what you
are doing. It is an awful hack, but it works.

Sorry for such a lame answer.

-doug
Jul 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by David Thielen | last post: by
2 posts views Thread by JYA | last post: by
6 posts views Thread by Andy Baker | last post: by
4 posts views Thread by arnuld | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.