VBScript为WScript.Echo创建函数别名 [英] VBScript create function alias for WScript.Echo

查看:205
本文介绍了VBScript为WScript.Echo创建函数别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道这没有任何意义。
但尽管如此。

I know that it has not any sense. But Nevertheless.

我想创建WScript.Echo的完整副本

I want to create full copy of WScript.Echo

我的方法是

Sub print(arguments)
    WScript.Echo arguments
End Sub

在WScript中。echo参数是字符串数组 WScript.Echo Arg1, Arg2,Arg3 ...要显示的可选字符串值。(可能不是数组,但看起来像字符串列表)

In WScript.Echo arguments are array of strings WScript.Echo Arg1, Arg2, Arg3... Optional string values to be displayed. (may be not array, but it looks like list of strings)

我的问题是如何将相同的参数传递给函数?

My question is how I can pass same argument to my function? Or may be it is not possible in general.

推荐答案

WScript.Echo是杂色子级(采用任意数量的参数)。您无法在VBScript中编写这样的Function / Subs / Method。在VBA中,您可以使用参数数组可选关键字。

WScript.Echo is a variadic Sub (taking an arbitrary number of arguments). You can't write such Functions/Subs/Method in VBScript. In VBA you can use a Parameter Array or the Optional keyword.

对于VBScript:您可以编写以数组a作为唯一参数和 WScript.Echo Join(a),但我对此感到怀疑

For VBScript: You could write a Sub that takes an array a as its only parameter and WScript.Echo Join(a), but I doubt that

print Array(...)

值得(付出的字母减少1 **)。

is worth (1** less letter to type) the effort.

更新:**显然我无法计数。

Update: ** Obviously I can't count.

这篇关于VBScript为WScript.Echo创建函数别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆