HELP: ASP JScript & VBScript interoperability

HELP: ASP JScript & VBScript interoperability

am 15.06.2007 18:42:32 von Andrew Wan

How can VBScript code access JScript code variables in the same ASP page?




Also, is this valid JScript code because ASP hasn't complained.



Basically it's like JScript's way of declaring classes.

How can VBScript code create a Section object?




Also, is it possible to nest

ASP didn't complain. But couldn't test whether the JScript functions Section
were member functions of the VBScript AClass.

Re: ASP JScript & VBScript interoperability

am 15.06.2007 19:22:42 von Anthony Jones

"Andrew Wan" wrote in message
news:OrvCZw2rHHA.3884@TK2MSFTNGP04.phx.gbl...
> How can VBScript code access JScript code variables in the same ASP page?
>
>
>
>
> Also, is this valid JScript code because ASP hasn't complained.

It won't because without a runat="server" attribute on the script element
the above is simply treated as content and sent to the client. The client
should've complained that Response is undefined.

To answer your question variables and functions declared at global scope are
accessible across the script boundaries.



>
>
>
> Basically it's like JScript's way of declaring classes.

Yeah but it's very JScript and is completely alien to VBScript.

>
> How can VBScript code create a Section object?
>
>

You need to create a factory function in the JScript:-

function newSection(a, b, c, d)
{
return new Section(a, b, c, d)
}

Now VBScript can use:-

Set obj = newSection(1,2,3,4)

>
>
> Also, is it possible to nest

No do it the other way around:-

Have a JScript.js file

then add this outside <% %> :-



Note it only makes sense to use this a function library, in-line code isn't
much use apart from code that may help create objects.

>
> ASP didn't complain. But couldn't test whether the JScript functions
Section
> were member functions of the VBScript AClass.
>
>

Again the runat attribute was missing.