使用VBScript函数JScript中,当语言= VBScript中

问题描述:

我知道它是可以使用的功能codeD在VBScript语言是否=JScript的如下:

I know it is possible to use functions coded in VBScript if language="JScript" as follows :

<%@ language="JScript" %>
<% Response.Write(myFunc()); %>
<script runat="server" language="vbscript">
    Function myFunc
        myFunc="test"
    End Function
</script>

然而,重构JScript中的脚本之前,我想知道,假定语言设置为VBScript中,有仍然使用VBScript函数在JScript中的可能性。或者,在这种情况下,只有其他方式和身边是可能的。

However, before refactoring a script in JScript, I wanted to know if, assuming the language is set to be VBScript, is there still a possibility to use VBScript functions in the JScript. Or, in that case, only the other way aroud is possible.

谢谢!

我使用JScript,VBScript和Python的以前测试过这一点。它可以调用从一种语言的功能在code从另一个块和对结果的工作。

I have tested this before using jscript, vbscript and Python. It is possible to call a function from one language in a block of code from another and work with the results.

有一些注意事项,但:

您需要确保该函数返回一个类型,其他语言可以识别;所以返回Python对象为VBScript将无法正常工作,但如果你使用简单的类型,如字符串,数字和布尔值是可能的。我想即使阵列VBScript和JScript之间的合作。

You need to make sure the function returns a type that the other language can recognize; so returning Python objects to vbscript will not work, but if you use simple types like strings, numbers and booleans it is possible. I think even arrays work between vbscript and jscript.

要考虑的第二件事是,有在这些脚本的服务器上的处理顺序的序列;我不知道到底再向是什么,但ASP会先处理一个语言,之后其他的。结果
这可能会导致奇怪的事情,当你code调用不同的语言功能,不能被发现的功能,因为ASP需要仍然处理该功能的语言发生。

The second thing to consider is that there is a sequence in the order in which the scripts are processed on the server; I don't know exactly anymore what it is, but ASP will first process one language, and after that the other.
This can lead to strange things happening when your code calls a function in a different language and that function can't be found because ASP needs to still process the language for that function.

只要你保持你的执行函数,并确保你只写code的这些功能​​以外在一个特定的语言,这不应该是一个问题。

As long as you keep your execution in functions and make sure you only write code outside of these functions in one specific language, this shouldn't be a problem.

HTH,

埃里克

编辑:这里的执行顺序的更多信息: http://www.kidslovepc.com /asp/order_execution.shtml

edit: here's more info on the order of execution: http://www.kidslovepc.com/asp/order_execution.shtml