经典ASP-将属性作为byref传递 [英] Classic ASP - passing a property as byref

查看:85
本文介绍了经典ASP-将属性作为byref传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在经典的ASP中,我有一个对象,将其称为 bob .然后,它具有一个名为 name 的属性,具有 let get 方法.

In classic ASP I have an object, call it bob. This then has a property called name, with let and get methods.

我的功能如下:

sub append(byref a, b)
    a = a & b
end sub

这仅仅是为了更快地将文本添加到变量中.我对 prepend 也有相同的要求,只是 a = b&一个.我知道说 bob.name = bob.name&"andy" ,但是我尝试使用上述功能,但它们都不起作用.

This is simply to make it quicker to add text to a variable. I also have the same for prepend, just it is a = b & a. I know it would be simple to say bob.name = bob.name & "andy", but I tried using the above functions and neither of them work.

我的称呼方式是追加bob.name,"andy" .谁能看到这是怎么回事?

The way I am calling it is append bob.name, "andy". Can anyone see what is wrong with this?

预先感谢,问候,理查德

Thanks in advance, Regards, Richard

推荐答案

不幸的是,这是VBScript的功能. http://msdn.microsoft.com/zh-CN/library/ee478101(v = vs.84).aspx 在类的参数"下.替代方法是使用一个函数.这是说明差异的示例.您可以使用"cscript filename.vbs"在命令行中运行.

Unfortunately this is a feature of VBScript. It is documented in http://msdn.microsoft.com/en-us/library/ee478101(v=vs.84).aspx under "Argument in a class". The alternative is to use a function. Here is an example illustrating the difference. You can run this from the command line using "cscript filename.vbs.

sub append (a, b)
   a = a & b
end sub

function Appendix(a, b)
   Appendix = a & b
end function

class ClsAA
   dim m_b
   dim m_a
end class
dim x(20)

a = "alpha"
b = "beta"
wscript.echo "variable works in both cases"
append a, b
wscript.echo "sub " & a
a = appendix(a, b)
wscript.echo "function " & a

x(10) = "delta"
wscript.echo "array works in both cases"
append x(10), b
wscript.echo "sub " & x(10)
x(10) = appendix( x(10), b)
wscript.echo "function " & x(10)

set objAA = new ClsAA
objAA.m_a = "gamma"
wscript.echo "Member only works in a function"
append objAA.m_a, b
wscript.echo "sub " & objAA.m_a
objAA.m_a = appendix(objAA.m_a, b)
wscript.echo "function " & objAA.m_a

这篇关于经典ASP-将属性作为byref传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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