VBScript GetRef()中的错误 [英] Bugs in VBScript GetRef()

查看:87
本文介绍了VBScript GetRef()中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人知道VBScript的GetRef()中是否有错误?我在Win2003Server上使用

VBScript版本5.6.8515 w / ASP。


有时它会返回一个VarType()所说的对象是vbObject。其他

次返回VarType()是vbEmpty。这让我很生气!


另外,有没有人知道对象的属性和方法是什么?GetRef()返回的



TIA。


-Mike

解决方案

嗨Mike,


感谢您使用社区。根据你的描述,函数

GetRef()随机返回错误的结果vbEmpty,你怀疑这可能是错误的b $ b b。我在数据库中搜索,但我还没发现这是一个已知的bug,

并且也没有类似的。我们知道函数GetRef()会返回对基于名称字符串的函数的引用。当它返回

vbEmpty时,意味着它找不到该功能。我建议你可以双击

检查你传入GetRef()的参数字符串,看看当前模块中是否有这样的函数。


如果您找到了重现问题的可靠方法,请告知我们。通过

这些信息,我们可以对问题进行深入研究,看看它是否是错误的。


问候,


Luke

Microsoft在线支持


安全! www.microsoft.com/security

(此帖子按原样提供,不作任何保证,并且不授予

权利。)


Mike Schinkel写道:< blockquote class =post_quotes>有没有人知道VBScript的GetRef()中是否有错误?我正在使用带有ASP的Win2003Server上的VBScript版本5.6.8515。

有时它返回一个VarType()所说的对象是vbObject。
其他时候它返回VarType()是vbEmpty。这让我很生气!


告诉我们如何重现这个问题。这从来没有发生在我身上。

另外,有没有人知道GetRef()返回的
对象的属性和方法是什么?



GetRef甚至可以在服务器端代码中工作吗?您可能想在m.p.scripting.vbscript中提出这个

问题。对于这个新闻组来说,这是一个小小的OT。

你将更有可能在那里找到vbscript专家。


Bob Barrows
-

Microsoft MVP - ASP / ASP.NET

请回复新闻组。这个电子邮件帐户是我的垃圾邮件陷阱所以我

不经常检查它。如果您必须离线回复,请删除

NO SPAM


Luke:

I弄清楚了。 GetRef()是一个搞砸的功能!假设下面的ASP文件(记录了会发生什么。在文件之后我会用英语解释):


<%

'' -------------------------------------------------- ----------------------------------

''以下代码输出以下内容:

''在FooBar

''0

''对象

''9

''对象

''HowDy

''在FooBar#2

Dim subref


设置subref = GetRef(" FooBar")

Response.Write VarType(subref)& "<峰; br>" '' - 执行FooBar写入在FooBar中,然后写入0。

'' - vbEmpty为0

Response.Write TypeName(subref)& "<峰; br>" '' - 写入对象


设置subref = GetRef(" FooBar2")

Response.Write VarType(subref)& "<峰; br>" '' - 写9 - vbObject是9

Response.Write TypeName(subref)& "<峰; br>" '' - 写'对象'

subref(" Howdy")'' - 执行FooBar2,写Howdy然后在FooBar#2

Sub FooBar()

Response.Write"在FooBar< br>"

End Sub


Sub FooBar2(x)

Response.Write x& "< br>"

Response.Write"在FooBar#2< br>"

End Sub

'' -------------------------------------------------- ----------------------------------

%>


基本上,如果你将subref = GetRef(" NoParamSub")分配给NoParamSub是一个没有参数的Sub,那么通过将它传递给VarType()来执行它,并且返回值为子返回被解释为零,这就是VarType(subref)返回0的原因。

基本上,如果你将subref = GetRef(" HasParamsSub")分配到whereHasParamsSub是一个Sub一个或多个参数,然后传递它作为对象传递给VarType(),VarType(subref)返回9(9是vbObject的值)。


将NoParamSub和HasParamsSub的subref传递给TypeName()会返回Object,这就是我必须使用的。我想看VarType()修复为VarType返回9(GetRef(" NoParamSub"))),但我不会屏住呼吸。


基本上,我真正需要的是vbscript 中的以下一组例程:


IsSub()'' - 告诉我全局命名空间中是否存在子句

IsFunction()'' - 告诉我全局命名空间中是否存在函数

IsMethod()'' - 告诉我对象是否存在子函数或函数/>
IsProperty()'' - 告诉我对象是否存在属性

ParameterCount()'' - 告诉我子或函数定义了多少参数

参数()'' - 返回给定子或函数的参数名列表

IsFunction()'' - 告诉我全局命名空间中是否存在函数
CallByName()'' - 让我通过名称和可选参数执行子或函数

CallStack()'' - 返回对象具有源文件和调用程序行数的数组对象


如何获得这些功能? VBScript中有没有我不知道怎么样?


此外,GetRef返回的对象是什么样的?它有属性或方法吗?


TIA。


-Mike

P.S.如果你能把它转发给Eric Lippert,我们将不胜感激。


" [MSFT]" <卢****** @ online.microsoft.com>在留言新闻中写道:eK ************** @ cpmsftngxa06.phx.gbl ...

嗨迈克,

谢谢使用社区。根据你的描述,函数GetRef()随机返回错误的结果vbEmpty,你怀疑这可能是bug。我在数据库中搜索,但我还没有发现这是一个已知的错误,
并且也没有类似的错误。我们知道函数GetRef()将返回对基于名称字符串的函数的引用。当它返回
vbEmpty时,意味着它找不到该功能。我建议您可以双击
检查传入GetRef()的参数字符串,看当前模块中是否有这样的功能。

如果您找到了重现问题的可靠方法,请告诉我。有了这些信息,我们就可以对这个问题进行深入研究,看看它是不是错误。

问候,

卢克
Microsoft在线支持

获得安全! www.microsoft.com/security
(此帖已提供按原样,没有保证,也没有赋予
权利。)



Does anyone know if there are bugs in VBScript''s GetRef()? I''m using
VBScript Version 5.6.8515 on Win2003Server w/ASP.

Sometimes it returns an object that VarType() says is a vbObject. Other
times it returns VarType() is vbEmpty. This is driving me mad!

Also, does anyone know what the properties and methods are for the object
returned by GetRef()?

TIA.

-Mike

解决方案

Hi Mike,

Thank you for using the community. From your description, the function
GetRef() returns incorrect result vbEmpty randomly and you suspect this may
be bug. I search in the database, but I haven''t found this is a known bug,
and there isn''t a similar one also. As we know function GetRef() will
return a reference to a function based a name string. When it return
vbEmpty, it mean it failed to find the function. I suggest you may double
check the parameter string you passed into GetRef(), to see if there is
such a function in current module.

If you found a solid way to reproduce the problem, please let me know. With
these information, we can perform deep research on the issue to see if it
is bug.

Regards,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


Mike Schinkel wrote:

Does anyone know if there are bugs in VBScript''s GetRef()? I''m using
VBScript Version 5.6.8515 on Win2003Server w/ASP.

Sometimes it returns an object that VarType() says is a vbObject.
Other times it returns VarType() is vbEmpty. This is driving me mad!

Show us how to reproduce the problem. This has never happened to me.
Also, does anyone know what the properties and methods are for the
object returned by GetRef()?


Does GetRef even work in server-side code? You may want to pose this
question in m.p.scripting.vbscript. It''s a little OT for this newsgroup.
You''ll be more likely to find the vbscript experts over there.

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don''t check it very often. If you must reply off-line, then remove the
"NO SPAM"


Luke:
I figured it out. GetRef() is one screwed up function! Assume the following ASP file (it is documented for what happens. After the file I''ll explain in english):

<%
''------------------------------------------------------------------------------------
''The following code outputs the following:
''In FooBar
''0
''Object
''9
''Object
''HowDy
''In FooBar#2
Dim subref

Set subref= GetRef( "FooBar" )
Response.Write VarType(subref)& "<br>" ''-- Executes FooBar writing "In FooBar", then writes "0"
''-- vbEmpty is 0
Response.Write TypeName(subref)& "<br>" ''-- Writes "Object"

Set subref= GetRef( "FooBar2" )
Response.Write VarType(subref)& "<br>" ''-- Writes "9" -- vbObject is 9
Response.Write TypeName(subref)& "<br>" ''-- Writes "Object"
subref("Howdy") ''-- Executes FooBar2, writes "Howdy" then "In FooBar#2"
Sub FooBar()
Response.Write "In FooBar<br>"
End Sub

Sub FooBar2(x)
Response.Write x & "<br>"
Response.Write "In FooBar#2<br>"
End Sub
''------------------------------------------------------------------------------------
%>

Basically, if you assign subref= GetRef("NoParamSub") to where NoParamSub is a Sub with no parameters, then accessing it by passing it to VarType() executes the sub, and the return value of the sub returns is interpretted as zero, which is why VarType(subref) returns 0.

Basically, if you assing subref= GetRef("HasParamsSub") to whereHasParamsSub is a Sub with one or more parameters, then passing it is passed to VarType() as an object and VarType(subref) returns 9 (9 is the value of vbObject).

Passing subref for both NoParamSub and HasParamsSub to TypeName() returns "Object", which is what I''ll have to use. I''d like to see VarType() fixed to return 9 for VarType(GetRef("NoParamSub")), but I won''t hold my breath.

BASICALLY, what I REALLY need is the following set of routines in vbscript:

IsSub() ''-- Tells me if a sub exists in global namespace
IsFunction() ''-- Tells me if a function exists in global namespace
IsMethod() ''-- Tells me if a sub or function exists for an object
IsProperty() ''-- Tells me if a property exists for an object
ParameterCount() ''-- Tells me how many parameters a sub or function has defined
Parameters() ''-- Returns list of parameter names for given sub or function
IsFunction() ''-- Tells me if a function exists in global namespace
CallByName() ''-- Lets me execute a sub or function by name with optional parameters
CallStack() ''-- Returns array objects where the objects have Source File and Line Number of calling programs

How can I get each of these features? Are any in VBScript and I just don''t know how?

Also, what does the object returned by GetRef look like? Does it have properties or methods?

TIA.

-Mike
P.S. If you can forward this to Eric Lippert, it would be greatly appreciated.

"[MSFT]" <lu******@online.microsoft.com> wrote in message news:eK**************@cpmsftngxa06.phx.gbl...

Hi Mike,

Thank you for using the community. From your description, the function
GetRef() returns incorrect result vbEmpty randomly and you suspect this may
be bug. I search in the database, but I haven''t found this is a known bug,
and there isn''t a similar one also. As we know function GetRef() will
return a reference to a function based a name string. When it return
vbEmpty, it mean it failed to find the function. I suggest you may double
check the parameter string you passed into GetRef(), to see if there is
such a function in current module.

If you found a solid way to reproduce the problem, please let me know. With
these information, we can perform deep research on the issue to see if it
is bug.

Regards,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



这篇关于VBScript GetRef()中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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