【发布时间】:2014-07-22 08:05:21
【问题描述】:
我正在尝试编写一个 JScript 函数,该函数接受可以由 cscript.exe 执行的可变数量的参数。根据此处的 Microsoft 文档http://msdn.microsoft.com/en-us/library/7yy9shf1(v=vs.90).aspx,最后一个函数参数可以是数组,但必须是类型数组。试过这个,cscript.exe 抱怨“:”附近的语法错误。
然后我尝试了一个更简单的示例,只有一个类型的参数:
<job id="Test">
<script language="JScript">
// Declare a function that takes an int and returns a String.
function Ordinal(num : int) : String{
switch(num % 10) {
case 1: return num + "st";
case 2: return num + "nd";
case 3: return num + "rd";
default: return num + "th";
}
}
// Test the function.
print(Ordinal(42));
print(Ordinal(1));
</script>
</job>
我将它保存为“test.wsf”,用:
cscript.exe //NoLogo test.wsf
仍然遇到同样的错误。 cscript.exe 不能使用类型化参数(和可变参数函数)吗?
【问题讨论】: