MeadCo ScriptX 5.0

December, 1999

Download this document set (37Kb zip)

Contents

Overview
How to put ScriptX on an HTML page
HTML Printing
General scripting extensions
Dynamic Event Binding (DEB)
DHTML dialogs
JScript: SafeArrays, Invoke 'ByRef', Formatting
Internet Explorer specific functionality
Technical support
Reference
 
Summary of examples
Basic and Advanced Printing
Dynamic Event Binding with JScript and VBScript (Windows Scripting Host»)
Modal HTML Dialog
SafeArrays with JScript
Invoke 'By Ref' with JScript
Formatting with JScript
OleView-based Object Viewer

Overview

MeadCo ScriptX is a non-visual ActiveX control, originally designed to extend the scripting capabilities of the standard Microsoft Scripting Languages JScript» and VBScript» and add more resemblance between the two. Currently the functionality provided by ScriptX can be conditionally grouped under the following headings:

The basic functionality of ScriptX is licensed free of charge. With the ScriptX 5.0 release we added some advanced printing features which are only accessible in the presence of a paid-for MeadCo Security Manager publishing license

How to put ScriptX on an HTML page

ScriptX comes in two signed CABs: ScriptX.cab or smsx.cab, both of which are part of a download package obtainable from the ScriptX site». Authors should select one of them to reference from an HTML page. ScriptX.cab contains only the ScriptX component (MCScriptX.dll) to be used whenever the basic functionality is enough:

<object id=factory style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  viewastext codebase="ScriptX.cab#Version=5,0,5,35">
</object>

The viewastext parameter prevents an authoring tool like FrontPage or Visual Interdev from instantiating the object at design time.

smsx.cab contains both the MeadCo ScriptX and Security Manager binaries required to publish content that uses advanced printing:

<!-- MeadCo Security Manager -->
<object viewastext style="display:none"
  classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
  codebase="smsx.cab#Version=5,0,5,35">
  <param name="GUID" value="{9bc82a21-b8c9-11d3-b934-002018654e2e}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

<!-- MeadCo ScriptX -->
<object id=factory viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  codebase="smsx.cab#Version=5,0,5,35">
</object>

Note: the {9bc82a21-b8c9-11d3-b934-002018654e2e} value of the GUID parameter used above identifies the MeadCo evaluation license that authors may use to experiment with Advanced printing capabilities. The license validates local filesystem (file://) and local website (http://localhost/) content for evaluation purposes only on a single development computer. Registered customers are issued with an unique license identifier and a signed sxlic.mlf file. See the licensing» page for more details.

HTML Printing

ScriptX became well know for its HTML printing capabilties following our MSDN publication». Version 1.0 provided scripted control of the printing of HTML frame or window content (with or without a prompt), and the specification by script of printing parameters such as headers, footers, page orientation and margins.

ScriptX 5.0 extends basic printing functionality with some powerful new features:

Features marked with * require licensing» from MeadCo.

Important information on changes from version 1.0.

ScriptX 5.0 is backwards compatible. A number of issues have been resolved since version 1.0, and we strongly recommend that you upgrade your <OBJECT> tags to version 5.0.

The following code snippet illustrates how to customize various printing settings:

<script>
function SetPrintSettings() {
  // -- extended features
  factory.printing.SetMarginMeasure(2) // measure margins in inches
  factory.printing.SetPageRange(false, 1, 3) // need pages from 1 to 3
  factory.printing.copies = 2
  factory.printing.collate = true
  factory.printing.paperSize = "A4"
  factory.printing.paperSource = "Manual feed"
  factory.printing.printer = "HP DeskJet 870C"

  // -- basic features
  factory.printing.header = "This is MeadCo"
  factory.printing.footer = "Advanced Printing by ScriptX 5.0"
  factory.printing.portrait = false
  factory.printing.leftMargin = 1.0
  factory.printing.topMargin = 1.0
  factory.printing.rightMargin = 1.0
  factory.printing.bottomMargin = 1.0
}
</script>

A subtle JScript issue may occur when setting a printer name that contains back slashes. Don't forget to double the slashes:

factory.printing.printer = "\\\\FS-LYS-01\\HP5n-759" // print to \\FS-LYS-01\HP5n-759

To print specific information as part of the header or footer, include the following characters as part of the text:

Shorthand Meaning
&w Window title
&u Page address (URL)
&d Date in short format (as specified by Regional Settings in Control Panel)
&D Date in long format (as specified by Regional Settings in Control Panel)
&t Time in the format specified by Regional Settings in Control Panel
&T Time in 24-hour format
&p Current page number
&P Total number of pages
&& A single ampersand (&)
&b The text immediately following these characters as centered.
&b&b The text immediately following the first "&b" as centered, and the text following the second "&b" as right-justified.

Here are some illustrative examples of ScriptX basic and advanced printing.

See also: printing, header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, Print, DoPrint, PrintHTML, SetPageRange, SetMarginMeasure.

General scripting extensions

Dynamic Event Binding (DEB)

As its name may indicate, DEB enables the binding/unbinding of a script handler to any ActiveX object event on the fly. It works well for all Active Scripting hosts: WSH, HTML or custom.

Another useful DEB feature is the ability to 'sleep' the script execution (with an optional timeout) without any CPU 'eating' until an event occurs.  'Sleep' is conceptually close to VB's DoEvents» statement in that it serves the application message loop.

The best way to illustrate DEB is by example. Here is a Windows Scripting Host (WSH») example in both JScript and VBScript that creates and navigates an instance of the InternetExplorer» object and hooks up to its events.

See also: eventSink, NewEventSink, Wait, CancelWait.

DHTML dialogs

Here is an example of a native look & feel HTML dialog.

See also: ShowHtmlDialog.

JScript: SafeArrays, Invoke 'ByRef', Formatting

These extensions were designed to provide JScript with more resemblance to VBScript.

Jscript has limited read-only support for VB Arrays» (known also as SafeArrays) with a VBArray» object. ScriptX allows the creation of -- and direct access to -- a SafeArray with JScript. It's now possible to convert a JScript Array» to a SafeArray. Note that only single dimension SafeArrays are supported. Here is an example illustrating SafeArrays with JScript.

See also: Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet, VarType

Invoke 'ByRef' was developed to allow JScript to call ActiveX controls that take byref arguments. It also allows OLE errors that the calling method may return to be handled, and any corresponding script exceptions to be avoided. Here is an example illustrating how to use InvokeByRefResult with JScript.

See also: InvokeByRef, InvokeByRefResult.

Formatting functions match those of VBScript. They require the newer OLE Automation binaries to be available (they're part of Windows 98, come with Internet Explorer 5, or can be downloaded as part of free Visual Basic 6.0 Run-Time», see MSKB Q192461»). Here is an example of JScript formatting.

See also: Format, FormatCurrency», FormatDateTime», FormatNumber», FormatPercent».

Object Viewer

It's possible to discover -- on the fly -- which methods and properties an object supports. Microsoft's OleViewer» is required and is available for free download». Here is an example of how to use the object viewer which shows the object model of an HTML window» and the ScriptX factory object itself.

See also: BrowseObject.

Other

See also: Shutdown, IsClosed, GetComponentVersion, MessageBeep, MessageBox, WinHelp, HtmlHelp.

Internet Explorer specific functionality

When ScriptX is hosted as an <OBJECT> on an HTML page it provides the following Internet Explorer specific functionality:

Technical support

We provide free peer-to-peer technical support at the public ScriptX Newsgroup: news://news.the-internet-eye.com/meadco.scriptx. Priority technical support is available to our licensee customers at scriptx@meadroid.com.


Reference

Objects

factory, js, printing, eventSink

Properties

script, baseURL, relativeURL, printing, js, sourceText, header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, printBackground, handler, src, ctx

Methods

NewEventSink, IsClosed, Shutdown, ShowHtmlDialog, MessageBeep, MessageBox, DoPrint, Wait, CancelWait, IsIEBuildGE, OnDocumentComplete, GetComponentVersion, Print, SetPageRange, PrintHTML, SetMarginMeasure, GetMarginMeasure, Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet, Format, FormatCurrency, FormatDateTime, FormatNumber, FormatPercent, InvokeByRef, InvokeByRefResult, Unadvise, IsSpooling, PrintXML, EnumPrinters, DefaultPrinter, EnumJobs, OwnQueue

Objects

factory


Description

Represents the ScriptX object itself as it is named on an HTML page. It's possible to create a ScriptX instance dynamically with the JScript new ActiveXObject» or the VBScript CreateObject». In such cases the Shutdown method should be called when ScriptX is no longer being used.

Examples

HTML page:

<object id=factory style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  viewastext codebase="ScriptX.cab#Version=5,0,5,35">
</object>

WSH» script (JScript):

var factory = new ActiveXObject("ScriptX.Factory")
factory.printing.PrintHTML("http://msdn.microsoft.com/workshop/author/script/dhtmlprint.asp")
factory.Shutdown()

ASP page (VBScript):

<%
 set factory = CreateObject("ScriptX.Factory")
 factory.printing.PrintHTML "http://localhost/orders/order.asp?number=" & Request.Form("number")
 factory.Shutdown
 set factory = nothing
%>

Properties

script, baseURL, relativeURL, printing, js, sourceText

Methods

NewEventSink, IsClosed, Shutdown, ShowHtmlDialog, MessageBeep, MessageBox, BrowseObject, DoPrint, PageSetup, WinHelp, HtmlHelp, Timeout, KillTimeout, Wait, CancelWait, IsIEBuildGE, OnDocumentComplete, GetComponentVersion

printing


Description

Represents the printing facilities of ScriptX. See HTML Printing for more information and examples.

Properties

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize

Methods

Print, SetPageRange, PrintHTML, SetMarginMeasure, IsSpooling, PrintXML, EnumPrinters

Applies To

factory

js


Description

Represents ScriptX helper facilities for JScript. See JScript: SafeArrays, Invoke 'ByRef', Formatting for more information and examples.

Methods

Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet, Format, FormatCurrency, FormatDateTime, FormatNumber, FormatPercent, InvokeByRef, InvokeByRefResult, VarType

Applies To

factory

eventSink


Description

An object used to connect script handlers to, or disconnect them from, events of an ActiveX control. The object is created dynamically with the NewEventSink method. See Dynamic Event Binding (DEB) for more information.

Properties

handler, src, ctx

Methods

Wait, CancelWait, Unadvise

See Also

NewEventSink, Timeout

Properties

script


Description

This property is for use with dynamic event binding, when a ScriptX object is created dynamically with VBscript. In this case the script namespace object should be assigned to this property, because ScriptX looks for an event handler by name. See the example below.

Syntax

factory.script = object

Settings

This read/write property takes an object that has all the event handlers defined within.

Applies To

factory

Example

' Handle events from browser
Set Browser = CreateObject("InternetExplorer.Application")
Browser.Visible = true

Set Factory = CreateObject("ScriptX.Factory")
Factory.script = me
Set Sink = Factory.NewEventSink(Browser)
Sink("BeforeNavigate2")="BeforeNavigate2"
Sink("DocumentComplete")="DocumentComplete"
Sink("OnQuit")="OnQuit"

Sub BeforeNavigate2(ByVal pDisp, URL, Flags, TargetFrameName, PostData, Headers, Cancel)
' handling code
End Sub

Sub DocumentComplete(ByVal pDisp, URL)
' handling code
End Sub

Sub OnQuit
' handling code
End Sub

See Also

NewEventSink

baseURL


Description

This property is for use in an HTML script. It returns a full URL based upon the URL of the hosting document.

Syntax

fullUrl = factory.baseURL[(url)]

Settings

This is a read-only property which returns either the full URL of the hosting document or the base url of the document's URL.

Applies To

factory

Example

<script>
function window.onload() {
  childWindow.navigate(factory.baseURL("loaded.htm"))
}
</script>

See Also

relativeURL

relativeURL


Description

This property is for use in an HTML script. It returns the URL relative to the hosting document's URL.

Syntax

relUrl = factory.relativeURL[(url)]

Settings

This is a read-only property.

Applies To

factory

See Also

baseURL

sourceText


Description

This property is for use in an HTML script. It retrieves the raw HTML source of the hosting document.

Syntax

htmlText = factory.sourceText

Settings

This is a read-only property.

Applies To

factory

header


Description

Specifies the string to be used as the header for HTML print-outs. See HTML Printing for more information and examples.

Syntax

printing.header = sHeader

Settings

This is a read/write property.

Applies To

printing

See Also

footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

footer


Description

Specifies the string to be used as the footer for HTML print-outs. See HTML Printing for more information and examples.

Syntax

printing.footer = sFooter

Settings

This is a read/write property.

Applies To

printing

See Also

header, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

portrait


Description

Specifies the page orientation for HTML print-outs. See HTML Printing for more information and examples.

Syntax

printing.portrait = bool

Settings

This is a read/write property. Use true to specify portrait and false for landscape.

Applies To

printing

See Also

header, footer, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

leftMargin


Description

Specifies the left margin for HTML print-outs. ScriptX uses the default units of measure of the user's system (could be either inches or millimeters). In a broad network environment default units are certain to vary, so an author should specify the SetMarginMeasure property. See HTML Printing for more information and examples.

Syntax

printing.leftMargin = numMargin

Settings

This is a read/write property.

Applies To

printing

See Also

header, footer, portrait, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

rightMargin


Description

Specifies the right margin for HTML print-outs. ScriptX uses the default units of measure of the user's system (could be either inches or millimeters). In a broad network environment default units are certain to vary, so an author should specify the SetMarginMeasure property. See HTML Printing for more information and examples.

Syntax

printing.rightMargin = numMargin

Settings

This is a read/write property.

Applies To

printing

See Also

header, footer, portrait, leftMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

topMargin


Description

Specifies the top margin for HTML print-outs. ScriptX uses the default units of measure of the user's system (could be either inches or millimeters). In a broad network environment default units are certain to vary, so an author should specify the SetMarginMeasure property. See HTML Printing for more information and examples.

Syntax

printing.topMargin = numMargin

Settings

This is a read/write property.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

bottomMargin


Description

Specifies the bottom margin for HTML print-outs. ScriptX uses the default units of measure of the user's system (could be either inches or millimeters). In a broad network environment default units are certain to vary, so an author should specify the SetMarginMeasure property. See HTML Printing for more information and examples.

Syntax

printing.bottomMargin = numMargin

Settings

This a read/write property.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, paperSize, paperSource, copies, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

paperSize


Description

Specifies the paper size for HTML print-outs. Only the paper size strings as they appear on Internet Explorer's "Page Setup" dialog for the selected printer can be specified. To use this property, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.paperSize = sPaperSize

Settings

This is a write-only property.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSource, copies, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

paperSource


Description

Specifies the paper source for HTML print-outs. Only the paper source strings as they appear on Internet Explorer's "Page Setup" dialog for the selected printer can be specified. To use this property, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.paperSource = sPaperSize

Settings

This is a write-only property.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, copies, collate, printer, printBackground, fontSize, Print, SetPageRange, PrintHTML, SetMarginMeasure

copies


Description

Specifies the number of copies for HTML print-outs. To use this property, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.copies = numCopies

Settings

This a write-only property.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, collate, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

collate


Description

Specifies whether or not to collate the pages of HTML print-outs when more than one copy is printed. To use this property, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.collate = bool

Settings

This is a write-only property. Use true to collate.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, printer, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

printer


Description

Specifies the printer to print to. Only the printer names as they appear on Internet Explorer's "Print" dialog can be specified. To use this property, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.printer = sPrinterName

Settings

This a write-only property. With JScript, take care to double a backslash if one appears in the printer name.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, fontSize, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

fontSize


Description

Specifies the font size for HTML print-outs. 0 corresponds to smallest, 4 to largest. This setting doesn't affect the font size set with CSS. To use this property, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.fontSize = numSize

Settings

This is a write-only property.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, printBackground, Print, SetPageRange, PrintHTML, SetMarginMeasure

printBackground


Description

Specifies whether or not to print a page's background colors and images. To use this property, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.printBackground = true|false

Settings

This is a write-only property.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, Print, SetPageRange, PrintHTML, SetMarginMeasure

handler


Description

This is the default property of the eventSink object. It is used to connect or disconnect a script event handler to or from a specified event. See dynamic event binding for more information.

Syntax

eventSink.handler(sEventName) = EventHandler

or

eventSink(sEventName) = EventHandler

or

eventSink(sEventName) = null

Settings

This is a read/write property. EventHandler can be either the string name of a script function or a direct function reference. null is used to disconnect the event hander.

Example

sink("StatusTextChange") = onStatusTextChange
function onStatusTextChange(Text) { /* handling code */ }

Applies To

eventSink

See Also

eventSink, src, ctx, NewEventSink

src


Description

Specify the event source object passed to NewEventSink. See dynamic event binding for more information.

Settings

This is a read-only property.

Applies To

eventSink

See Also

handler, ctx, NewEventSink

ctx


Description

Specify the context value assigned to the eventSink object with NewEventSink. See dynamic event binding for more information.

Settings

This is a read-only property.

Applies To

eventSink

See Also

handler, src, NewEventSink

Methods

NewEventSink


Description

Creates a new event sink for a given object for dynamic event binding. To handle an event, a script handler must be assigned to the sink with the handler property. An optional context value can be passed to be available at the event handler when the event occurs.

Syntax

eventSink = factory.NewEventSink(src[, ctx])

Parameter Description
src (Object) the object to handle events from
ctx (Any type) optional context value

Return Value

Returns a new eventSink object. At event time the object is available to the script handler via implicit this (JScript) or me (VBScript) reference.

Applies To

factory

Example

var browser = new ActiveXObject("InternetExplorer.Application")
var sink = factory.NewEventSink(browser)
sink("StatusTextChange") = onStatusTextChange
sink("NavigateComplete2") = onNavigateComplete2
sink("DocumentComplete") = onDocumentComplete
sink("OnQuit") = onQuit
browser.Navigate2("http://www.meadroid.com")
sink.Wait()
// ...
factory.Shutdown()

// handlers
function onStatusTextChange(Text) { /* handling code */ }
function onNavigateComplete2(pDisp, URL) { /* handling code */ }
function onDocumentComplete(pDisp, URL) { this.CancelWait() }
function onQuit() { this.Unadvise() }

See Also

eventSink, handler, src, ctx, Wait, CancelWait, Unadvise, Shutdown

Wait


Description

Suspend (sleeps) the script execution for a specified timeout or until CancelWait is called. Events are serviced during sleep.

Syntax

object.Wait([timeout])

Parameter Description
timeout (Number) the optional timeout in milliseconds, -1 by default means to sleep until CancelWait is called.

Return Value

Returns true if the sleep was timed out.

Applies To

factory, eventSink

Example

var browser = new ActiveXObject("InternetExplorer.Application")
var sink = factory.NewEventSink(browser)
sink("DocumentComplete") = onDocumentComplete
sink("OnQuit") = onQuit
browser.Navigate2("http://www.meadroid.com")
sink.Wait()
// ...
factory.Shutdown()

// handlers
function onDocumentComplete(pDisp, URL) { this.CancelWait() }
function onQuit() { this.Unadvise() }

See Also

CancelWait

CancelWait


Description

Cancels the pending sleep (that is, the active Wait call).

Syntax

object.CancelWait()

Applies To

factory, eventSink

Example

var browser = new ActiveXObject("InternetExplorer.Application")
var sink = factory.NewEventSink(browser)
sink("StatusTextChange") = onStatusTextChange
sink("NavigateComplete2") = onNavigateComplete2
sink("DocumentComplete") = onDocumentComplete
sink("OnQuit") = onQuit
browser.Navigate2("http://www.meadroid.com")
sink.Wait()
// ...
factory.Shutdown()

// handlers
function onStatusTextChange(Text) { /* handling code */ }
function onNavigateComplete2(pDisp, URL) { /* handling code */ }
function onDocumentComplete(pDisp, URL) { this.CancelWait() }
function onQuit() { this.Unadvise() }

See Also

Wait

Unadvise


Description

Disconnects (unadvises) the eventSink object from its event source.

Syntax

eventSink.Unadvise()

Applies To

eventSink

Example

var browser = new ActiveXObject("InternetExplorer.Application")
var sink = factory.NewEventSink(browser)
sink("OnQuit") = onQuit
browser.Navigate2("http://www.meadroid.com")
sink.Wait()

// handlers
function onQuit() { this.Unadvise() }

See Also

NewEventSink

Shutdown


Description

The clean-up method for ScriptX. Should be called in cases where a dynamically created ScriptX object is no longer being used. All active event sinks get disconnected.

Syntax

factory.Shutdown()

Applies To

factory

IsClosed


Description

Checks whether or not the remote object is shut down. E.g. this can be a pop-up HTML window.

Syntax

closed = factory.IsClosed(obj)

Parameter Description
obj (Object) the remote object to check.

Applies To

factory

Example

function IsWindowClosed(popup) {
  return !popup || factory.IsClosed(popup) || popup.closed;
}

ShowHtmlDialog


Description

Invokes a native look & feel modal HTML dialog. See DHTML dialogs for more information and an example.

Syntax

result = factory.ShowHtmlDialog(url, argIn[, options])

Parameter Description
url (String) the URL of HTML page to be a dialog
argIn (Any type) input parameter to reference within dialog
options (String) optional features. See showModalDialog» on MSDN.

Applies To

factory

See Also

showModalDialog»

DoPrint


Description

The alias for the Print method (for compatibility reasons).

Applies To

factory

See Also

printing, Print, PrintHTML

Print


Description

Prints the specified frame using the current printing settings. See HTML Printing for more information and examples.

Syntax

printing.Print([prompt[, frameOrWindow]])

Parameter Description
prompt (Bool) whether or not to prompt
frameOrWindow (Object) optional HTML frame or window» to print. By default, the hosting window is printed

Return Value

Returns false if a user cancels the printing.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, SetPageRange, PrintHTML, SetMarginMeasure

PrintHTML


Description

Prints the specified URL using the current printing settings. To use this method, a publishing license» is required. See HTML Printing for more information and examples. This method is asynchronous. It returns before the HTML document is downloaded and printed.

PrintHTML may be used to organize a printing queue in a separate process, in which case the current window printing settings are kept unchanged; the download and print-out is queued and will be processed even if the calling window is closed. See OwnQueue for more details.

Syntax

printing.PrintHTML(url[, useDefault = false])

Parameter Description
url (String) URL to print
useDefault (Bool) directs the use of default settings to bypass hidden Page Setup and Print dialogs.

Applies To

printing

Examples

WSH» script (JScript):

var factory = new ActiveXObject("ScriptX.Factory")
factory.printing.PrintHTML("http://msdn.microsoft.com/workshop/author/script/dhtmlprint.asp")

ASP page (VBScript):

<%
 set factory = CreateObject("ScriptX.Factory")
 factory.printing.PrintHTML "http://localhost/orders/order.asp?number=" & Request.Form("number")
 set factory = nothing
%>

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, SetPageRange, Print, SetMarginMeasure, PrintXML, IsSpooling, EnumPrinters, OwnQueue

SetMarginMeasure


Description

Sets the units of measure for print-out margins. To use this method, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.SetMarginMeasure(units)

Parameter Description
units (Number) 1 stands for millimeters, 2 for inches.

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, SetMarginMeasure, Print, PrintHTML

SetPageRange


Description

Sets the page selection to print. To use this method, a publishing license» is required. See HTML Printing for more information and examples.

Syntax

printing.SetPageRange(selectionOnly[, from, to])

Parameter Description
selectionOnly (Bool) print the highlighted HTML selection only
from (Number) print from the page, 1-based. Use 0 to print all pages
to (Number) print to the page, 1-based

Applies To

printing

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, SetMarginMeasure, Print, PrintHTML

GetComponentVersion


Description

Retrieves the versioning information of a specified component.

Syntax

factory.GetComponentVersion(class, a, b, c, d)

Parameter Description
class (String) either class name or GUID
a, b, c, d (Number) variables to receive four digit version info

Examples

' VBScript
dim a, b, c, d
on error resume next
factory.GetComponentVersion "msxml", a, b, c, d
error = Err.Number
on error goto 0
if error = 0 then alert "msxml version: " & a & "." & b & "." & c & "." & d

Applies To

factory

Vec


Description

Creates a single-dimensional SafeArray (vector) of a specified size. See SafeArrays for more information and an example.

Syntax

vec = js.Vec(size)

Parameter Description
size (Number) number of elements in new vector

Return Value

Returns the value of a SafeArray type.

Applies To

js

See Also

VecFill, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet

VecFill


Description

Creates a one-dimensional SafeArray (vector) containing the specified elements. See SafeArrays for more information and an example.

Syntax

vec = js.VecFill(elem1[, elem2[, ...]])

Parameter Description
elem1...elemN (Any type) elements to fill the vector with

Return Value

Returns the value of a SafeArray type.

Applies To

js

See Also

Vec, VecCopy, VecFromArray, VecGetSize, VecResize, VecPut, VecGet

VecCopy


Description

Creates a copy of a specified one-dimensional SafeArray (vector). See SafeArrays for more information and an example.

Syntax

vec = js.VecCopy(srcVec)

Parameter Description
srcVec (SafeArray) source vector to make a copy of

Return Value

Returns the value of a SafeArray type.

Applies To

js

See Also

Vec, VecFill, VecFromArray, VecGetSize, VecResize, VecPut, VecGet

VecFromArray


Description

Creates a one-dimensional SafeArray (vector) from a JScript array. See SafeArrays for more information and an example.

Syntax

vec = js.VecFromArray(array)

Parameter Description
array (Array) a source JScript array

Return Value

Returns the value of a SafeArray type.

Applies To

js

See Also

Vec, VecFill, VecCopy, VecGetSize, VecResize, VecPut, VecGet

VecGetSize


Description

Retrieves the size of specified one-dimensional SafeArray (vector). See SafeArrays for more information and example.

Syntax

size = js.VecGetSize(vec)

Parameter Description
vec (SafeArray) vector

Return Value

Returns the size of the vector.

Applies To

js

See Also

Vec, VecFill, VecCopy, VecFromArray, VecResize, VecPut, VecGet

VecResize


Description

Changes the size of a specified one-dimensional SafeArray (vector). See SafeArrays for more information and an example.

Syntax

js.VecResize(vec, newSize)

Parameter Description
vec (SafeArray) vector
newSize (Number) new size of the vector

Applies To

js

See Also

Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecPut, VecGet

VecPut


Description

Puts the element at the specified position of a one-dimensional SafeArray (vector). See SafeArrays for more information and an example.

Syntax

js.VecPut(vec, pos, elem)

Parameter Description
vec (SafeArray) vector
pos (Number) position
elem (Any type) element to put at the position

Applies To

js

See Also

Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecGet

VecGet


Description

Retrieves the element at the specified position of a one-dimensional SafeArray (vector). See SafeArrays for more information and example.

Syntax

elem = js.VecGet(vec, pos)

Parameter Description
vec (SafeArray) vector
pos (Number) position

Return Value

Returns the element at the specified position.

Applies To

js

See Also

Vec, VecFill, VecCopy, VecFromArray, VecGetSize, VecPut

Format


Description

Formats the data according to the corresponding format specification. See Formatting for more information and an example.

Syntax

string = js.Format(strFormat[, param1[, param2[, ...]]])

Parameter Description
strFromat (String) the format-control specification. See remarks below
param1...param2 (Type as specifed at strFromat) paramters to format

Remarks

The format-control string contains format specifications that determine the output format for the arguments following the strFromat parameter. Format specifications, discussed below, always begin with a percent sign (%). If a percent sign is followed by a character that has no meaning as a format field, the character is not formatted (for example, %% produces a single percent-sign character).

The format-control string is read from left to right. When the first format specification (if any) is encountered, it causes the value of the first argument after the format-control string to be converted and copied to the output buffer according to the format specification. If there are more arguments than format specifications, the extra arguments are ignored. If there are not enough arguments for all of the format specifications, the results are undefined.

A format specification has the following form:

%[-][#][0][width][.precision]type

Each field is a single character or a number signifying a particular format option. The type characters that appear after the last optional format field determine whether the associated argument is interpreted as a character, a string, or a number. The simplest format specification contains only the percent sign and a type character (for example, %s). The optional fields control other aspects of the formatting. Following are the optional and required fields and their meanings:

Field Meaning
Pad the output with blanks or zeros to the right to fill the field width, justifying output to the left. If this field is omitted, the output is padded to the left, justifying it to the right.
# Prefix hexadecimal values with 0x (lowercase) or 0X (uppercase).
0 Pad the output value with zeros to fill the field width. If this field is omitted, the output value is padded with blank spaces.
width Copy the specified minimum number of characters to the output buffer. The width field is a nonnegative integer. The width specification never causes a value to be truncated; if the number of characters in the output value is greater than the specified width, or if the width field is not present, all characters of the value are printed, subject to the precision specification.
.precision For numbers, copy the specified minimum number of digits to the output buffer. If the number of digits in the argument is less than the specified precision, the output value is padded on the left with zeros. The value is not truncated when the number of digits exceeds the specified precision. If the specified precision is 0 or omitted entirely, or if the period (.) appears without a number following it, the precision is set to 1.
For strings, copy the specified maximum number of characters to the output buffer.
type Output the corresponding argument as a character, a string, or a number. This field can be any of the following character sequences:


Sequence Insert
C A single character.
d A signed decimal integer argument. This sequence is equivalent to the i sequence.
i A signed decimal integer. This sequence is equivalent to the d sequence.
ls, lS A string.
u An unsigned integer argument.
x, X An unsigned hexadecimal integer in lowercase or uppercase.

Return Value

Returns the formatted string.

Applies To

js

See Also

FormatCurrency, FormatDateTime, FormatNumber, FormatPercent

FormatCurrency, FormatDateTime, FormatNumber, FormatPercent


Description

Formatting functions which match those of VBScript: Format, FormatCurrency», FormatDateTime», FormatNumber», FormatPercent». They require the newer OLE Automation binaries to be available. See Formatting for more information and example.

InvokeByRef


Description

Allows JScript to call a method of an ActiveX object that takes a parameter by reference. See Invoke 'ByRef' for more information.

Syntax

value = js.InvokeByRef(object, method, argArray)

Parameter Description
object (Object) object on which to call the method
method (String) method to call
argArray (Array) JScript array of arguments

Return Value

Returns the same result as a direct object.method(...) call.

Example

  // pack params to "args" array
  args = new Array("msxml", 0, 0, 0, 0)

  // call the "GetComponentVersion" method on "factory" object
  factory.js.InvokeByRef(factory, "GetComponentVersion", args)

  alert("MSXML Version: "+args[1]+"."+args[2]+"."+args[3]+"."+args[4])

Applies To

js

See Also

InvokeByRefResult

InvokeByRefResult


Description

Allows JScript to call a method of an ActiveX object that takes a parameter by reference, and handle a possible failure case. See Invoke 'ByRef' for more information.

Syntax

error = js.InvokeByRefResult(object, method, argArray)

Parameter Description
object (Object) object on which to call the method
method (String) method to call
argArray (Array) JScript array of arguments

Return Value

Returns the error code number of an object.method(...) call. Zero means the call has succeeded. The invocation result value (if applicable) is available as argArray.value.

Example

  // pack params to "args" array
  args = new Array("msxml", 0, 0, 0, 0)

  // call the "GetComponentVersion" method on "factory" object
  error = factory.js.InvokeByRefResult(factory, "GetComponentVersion", args)

  if ( error == 0 )
    alert("MSXML Version: "+args[1]+"."+args[2]+"."+args[3]+"."+args[4])
  else
    alert("Error: "+error)

Applies To

js

See Also

InvokeByRef

MessageBeep


Description

Plays a waveform sound. The waveform sound for each sound type is identified by an entry in the [sounds] section of the registry.

Syntax

factory.MessageBeep([type])

Parameter Description
type (Number) Specifies the sound type, as identified by an entry in the [sounds] section of the registry. This parameter can be one of the following values:
Value Sound
-1 Standard beep using the computer speaker
0x00000040 SystemAsterisk
0x00000030 SystemExclamation
0x00000010 SystemHand
0x00000020 SystemQuestion
0x00000000 SystemDefault

Applies To

factory

See Also

MessageBox

MessageBox


Description

Creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons.

Syntax

result = factory.MessageBeep(text[, caption[, type]])

Parameter Description
text (String) the message to display
caption (String) message box caption
type (Number) Specifies a set of bit flags that determine the contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags. Specify one of the following flags to indicate the buttons contained in the message box:
Value Sound
0x00000000 The message box contains one push button: OK. This is the default
0x00000001 The message box contains two push buttons: OK and Cancel
0x00000004 The message box contains two push buttons: Yes and No
0x00000003 The message box contains three push buttons: Yes, No, and Cancel
0x00000030 An exclamation-point icon appears in the message box
0x00000040 An icon consisting of a lowercase letter i in a circle appears in the message box
0x00000010 A stop-sign icon appears in the message box
0x00010000 The message box becomes the foreground window
0x00040000 The message box is created as topmost window

Return Value

The return value is one of the following menu-item values:

Value Meaning
3 Abort button was selected.
2 Cancel button was selected.
7 No button was selected.
1 OK button was selected.
6 Yes button was selected.

Applies To

factory

See Also

MessageBeep

OnDocumentComplete


Description

Notifies the caller about the completion of an HTML frame or window download.

Syntax

factory.OnDocumentComplete(frameOrWindow, callback)

Parameter Description
frameOrWindow (Object) frame or window object loading HTML content
callback (Object) references to JScript function object to be called upon download completition

Examples

var child = open("child.htm")
function onChildLoad() {
  alert("Window loaded: "+child.document.title)
}
factory.OnDocumentComplete(child, onChildLoad)

Applies To

factory

PrintXML


Description

Prints an XSL-bound XML file specified by URL using the current printing settings. To use this method, a publishing license» is required. This asynchronous method requires Internet Explorer 5. It returns before the XML document is downloaded and printed. See HTML Printing for more information and examples.

Syntax

printing.PrintXML(url[, useDefault = false])

Parameter Description
url (String) URL to print
useDefault (Bool) directs the use of default settings to bypass hidden Page Setup and Print dialogs.

Applies To

printing

Examples

WSH» script (JScript):

var factory = new ActiveXObject("ScriptX.Factory")
factory.printing.PrintXML("http://msdn.microsoft.com/workshop/author/script/dhtmlprint.xml")

ASP page (VBScript):

<%
 set factory = CreateObject("ScriptX.Factory")
 factory.printing.PrintXML("http://localhost/orders/order.asp?number=" & Request.Form("number")
 set factory = nothing
%>

See Also

header, footer, portrait, leftMargin, rightMargin, topMargin, bottomMargin, paperSize, paperSource, copies, collate, printer, fontSize, SetPageRange, Print, SetMarginMeasure, OwnQueue

IsSpooling


Description

Checks if there are any outstanding downloads in the queue created by PrintHTML or PrintXML calls. Before quitting, an application might like to check that asynchronous downloads are complete and spooled. The onbeforeunload» event is suitable for that.

Syntax

isSpooling = printing.IsSpooling()

Return Value

Returns a boolean value indicating whether or not there are still outstanding downloads to be printed

Example

<script>
var g_spooling = false;

function PrintAllDocs() {
  factory.printing.portrait = false;
  factory.printing.PrintXML(src1);
  factory.printing.PrintXML(src2);
  g_spooling = true;
  setTimer("checkSpooling()", 3000);
}

function CheckSpooling() {
  g_spooling = factory.printing.IsSpooling();
  if ( !g_spooling ) window.close()
}

function window.onbeforeclose() {
  if ( g_spooling ) return "The documents are still being printed!";
}
</script>

Applies To

printing

See Also

PrintHTML, PrintXML

EnumPrinters


Description

Enumerates locally-available printers. To use this method, a publishing license» is required.

Syntax

printerName = printing.EnumPrinters(index)

Parameter Description
index (Number) Zero-based index of the printer. Increment this value for each new EnumPrinters call

Return Value

Returns the string name of the next printer. An empty value means the enumeration is over.

Example

<script>
function window.onload() {
  for ( i = 0; str = factory.printing.EnumPrinters(i); i++ )
    alert("Printer name: "+str);
}
</script>

Applies To

printing

See Also

PrintHTML, PrintXML

DefaultPrinter


Description

Returns the name of the default printer (if any). To use this method, a publishing license» is required.

Syntax

printerName = printing.DefaultPrinter()

Applies To

printing

See Also

EnumPrinters, EnumJobs, printer

EnumJobs


Description

Enumerates active jobs on the given printer. To use this method, a publishing license» is required.

Syntax

var jobName = {}
status = printing
.EnumJobs(printerName, index, jobName)

Parameter Description
printerName (String) printer name to enumerate the jobs on
index (Number) Zero-based index of the job. Increment this value for each new EnumJobs call for given printerName
jobName (Object) obtains a name of the job (available as jobName[0])

Return Value

Returns the current status of the job. The bits have the following meaning:

Meaning Value
JOB_STATUS_PAUSED 0x00000001
JOB_STATUS_ERROR 0x00000002
JOB_STATUS_DELETING 0x00000004
JOB_STATUS_SPOOLING 0x00000008
JOB_STATUS_PRINTING 0x00000010
JOB_STATUS_OFFLINE 0x00000020
JOB_STATUS_PAPEROUT 0x00000040
JOB_STATUS_PRINTED 0x00000080
JOB_STATUS_DELETED 0x00000100
JOB_STATUS_BLOCKED_DEVQ 0x00000200
JOB_STATUS_USER_INTERVENTION 0x00000400
JOB_STATUS_RESTART 0x00000800

Example

<script>
function window.onload() {
  for ( i = 0; str = factory.printing.EnumPrinters(i); i++ )
    alert("Printer name: "+str);
}
</script>

Applies To

printing

See Also

EnumPrinters

OwnQueue


Description

OwnQueue is used to organize a printing queue in a separate process, in which case current window printing settings are kept unchanged; the download and print-out is queued with PrintHTML or PrintXML and will be processed even if the calling window is closed. To use this method, a publishing license» is required.

OwnQueue should be called before any PrintHTML or PrintXML commands.

Note: because a hidden Win32 process is created to serve the queue, the current page HTTP context (including possible login, authentication or SSL context) is invisible to it.

Syntax

printing.OwnQueue()

Example

<script>
function OutputHtml(html) {
  idOutput.insertAdjacentHTML("BeforeEnd", html);
  idOutput.scrollIntoView(false);
}

function EnumAll() {
  OutputHtml("Default printer: <b>"+factory.printing.DefaultPrinter()+"</b><br>");
  for ( i = 0; name = factory.printing.EnumPrinters(i); i++ ) {
    OutputHtml("Printer: <b>"+name+"</b><br>Job count: "+factory.printing.GetJobsCount(name)+"<br>");
    var jobName = new Object;
    for ( j = 0; status = factory.printing.EnumJobs(name, j, jobName); j++ )
      OutputHtml("Job: <b>"+jobName[0]+"</b>Status: "+new Number(status).toString(16)+"<br>");
  }
}

function window.onload() {
  EnumAll();
}
</script>

<p><small id=idOutput></small>

Applies To

printing

See Also

PrintHTML, PrintXML

GetMarginMeasure


Description

Returns the units of measure for print-out margins. To use this method, a publishing license» is required.

Syntax

units = printing.GetMarginMeasure()

Return Value

Returns the system default units of measure. 1 stands for millimeters, 2 for inches.

Applies To

printing

See Also

GetMarginMeasure, Print