Passing COM VB6 strings weirdness

  • Thread starter U-CDK_CHARLES\\Charles
  • Start date
U

U-CDK_CHARLES\\Charles

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
 
D

drs

U-CDK_CHARLES\Charles said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,951
Messages
2,570,113
Members
46,698
Latest member
alexxx

Latest Threads

Top