在command.xml中有
<KeyinHandler Keyin="mycmd test" Function="mytest"/>
调用mytest(string unparsed)成功。
请问command.xml中能否支持传递参数(不能是unparsed,这里只支持限定的字符串,如果下面的1/2),比如
<KeyinHandler Keyin="mycmd test 1" Function="mytest(1)"/>
<KeyinHandler Keyin="mycmd test 2" Function="mytest(2)"/>
我现在测试的结果,似乎command.xml不能带参数,顶多把unparsed的值传过去,不能限定指定的字符串。
谢谢。
不可以,只能传递字符传。
不好意思,可能没表达清楚。
假设有一个简化版函数
mytest(string A)
{
writeline(A);
}
能否实现通过keyin命令,mycmd test AAA调用mytest("A1"), mycmd test BBB调用mytest("B1"), 其中AAA是设定好的字符串(不是unparsed的任意字符串),如果输入mycmd test CCC,不调用。
还是必须为每个keyin命令准备一个不带参数的中转函数,然后在此函数内带参数去调用最终的函数。例如:
mycmd test AAA调用mytestA(), 然后在mytestA()里面去调用mytest("A1")。
谢谢郭老师。
应该是您描述的后一种。
Answer Verified By: Changsong Ling