SideBar
This article may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. To maintain the flow of the article, we've left these URLs in the text, but disabled the links.
MIND
VBScript and Remote Scripting
R
ecently Microsoft made Remote Scripting 1.0b available from the Scripting Web site at http://msdn.microsoft.com/scripting. This release doesn't include any exciting new features, but does fix some bugs and includes improved support for RS under Microsoft Internet Information Services 5.0 and Windows 2000.

Empty Space on the Top of RS Pages


      As illustrated in Figure A, in some cases when using Internet Explorer with RS, you may see an empty space at the top of the page. Looking more closely, you can see a little dot at the top of the page. This is the result of calling RSEnableRemoteScripting, which is mandatory to initialize RS. This function writes HTML code in the page like this:

<APPLET name=RSAspProxyApplet
        codebase='http://expoware/_ScriptLibrary'
        code=RSProxy.class
        height=0
        width=0>
</APPLET>
Figure A Extra Space in an RS Page
Figure A Extra Space in an RS Page

      While this is fine with Netscape's browsers, it introduces some white space if the page is viewed through Internet Explorer. You can work around this by explicitly hiding the applet using the style object. Add the following attribute to the previous <APPLET> tag:

style=display:none
      If you apply this change to the RS source code within the rs.htm file, RS won't work with browsers that have different support for Cascading Style Sheets and Dynamic HTML (namely, Netscape's browsers). You could also do this with script code executed inside a specific HTML page. Use VBScript to make sure Netscape's browsers ignore this modification, which would apply to Internet Explorer only. Or you could accomplish the same thing this way:

<BODY onload="RSAspProxyApplet.style.display='none'">
      Solving this problem requires you to know a fair amount about RS internals and in particular the ID of the Java-language applet providing the HTTP transport in this version of RS.

Using VBScript on the Server


      RS is based heavily on ECMAScript, but this doesn't mean that you cannot employ VBScript for writing the body of a method the remote object exposes. The public_description object—which is the central console gathering the whole programming interface of the object—must always be a JavaScript object. Once you've defined the prototype of the methods, you can implement them using any scripting language.
      The trick is using the special JavaScript Function keyword to create a new function on the fly. You pass that function a list of parameters and the command line. Everything must be a string.
function Description()  {
this.GetEmployeeInfo = DoGetEmployeeInfoAsRecordset;
this.CallVBMethod = Function('p1', 'VBFunc(p1)');
}

<script runat=server language="VBScript">
    Function VBFunc(p1)
•••
    End Function
</script>
      Then, you define the specific piece of code within a <SCRIPT> tag, paying attention to introduce the RUNAT=SERVER clause.

From the March 2000 issue of MSDN Magazine.

Page view tracker