nyrang 发表于 2011-4-26 19:32:46

[zmud 4.62] DDE 问题

我有一个python的DDE test server

import win32ui
from pywin.mfc import object
import dde
class MySystemTopic(object.Object):
def __init__(self):
object.Object.__init__(self, dde.CreateServerSystemTopic())
def Exec(self, cmd):
print "System Topic asked to exec", cmd
class MyOtherTopic(object.Object):
def __init__(self, topicName):
object.Object.__init__(self, dde.CreateTopic(topicName))
def Exec(self, cmd):
print "Other Topic asked to exec", cmd
class MyRequestTopic(object.Object):
def __init__(self, topicName):
topic = dde.CreateTopic(topicName)
topic.AddItem(dde.CreateStringItem(""))
object.Object.__init__(self, topic)
def Request(self, aString):
print "Request Topic asked to compute length of:", aString
return(str(len(aString)))
server = dde.CreateServer()
server.AddTopic(MySystemTopic())
server.AddTopic(MyOtherTopic("RunAnyCommand"))
server.AddTopic(MyRequestTopic("ComputeStringLength"))
server.Create('RunAny')
while 1:
win32ui.PumpWaitingMessages(0, -1)


在zmud 4.62 里面执行#DDE RunAny RunAnyCommand hihihi ,能够看到python里面print出来"Other Topic asked to exec hihihi".

用函数%dde, %ddeopen, %ddepoke,在mud里面都只显示“什么?”。显然是函数无法调用。

谁能告诉一下到底应该怎么用dde函数从一个dde server里面获取值?

bluse 发表于 2011-4-26 21:38:41

用函数%dde, %ddeopen, %ddepoke,在mud里面都只显示“什么?”。显然是函数无法调用。

谁能告诉一下到底应该怎么用dde函数从一个dde server里面获取值?




#dde相当于subroutine,%dde是函数所以要返回字符串值,你直接在命令行里执行%dde,返回的字符串就回送到mud,是没有意义的指令,所以有“什么”,你试试看#say %dde(..)

nyrang 发表于 2011-4-27 17:43:47

谢谢,#show #say 我昨天都试过了,今天发现问题在于调用错了,%dde是要返回值的,调用上面的RunAnyCommand是不行的,换成#say %dde(RunAny,ComputeStringLength,hihdfljaljfdlafd)就work了,thanks!
页: [1]
查看完整版本: [zmud 4.62] DDE 问题