Module: capeCodeHost

JavaScript functions for the CapeCode host, which is based on Ptolemy II and Java's Nashorn JavaScript engine.

This host supports version 1 accessors.

To implement this host, JavaScript.java does the following:

1) Load the nashornHost.js file, which realizes functions that are independent of Ptolemy II. 2) load this file (capeCodeHost.js) which overrides some of those function definitions. 3) Load localFunctions.js, which evaluates the accessor in the context that includes the overrides.

Version:
  • $$Id$$
Since:
  • Ptolemy II 11.0
Author:
  • Edward A. Lee, Contributor: Christopher Brooks
Source:

Methods

(inner) alert(message)

Pop up a dialog with the specified message. NOTE: This function is not required by the accessor specification, so accessors should not rely on it being present.

Parameters:
Name Type Description
message

The message

Source:

(inner) error(message)

Report an error. This implementation delegates to the host actor to report the error. In this implementation, the host actor has an error output port. If that port is connected to something, then the error message is sent to that port. Otherwise, the error is reported via a dialog or on stderr (the latter if running headless). This function should be used only for non-fatal errors, where it is OK to continue executing. For fatal errors, throw an exception.

Parameters:
Name Type Description
message

The message for the exception.

Source:

(inner) httpRequest(url, method, properties, body, timeout)

Perform a blocking HTTP request.

Parameters:
Name Type Description
url

The url for the request, method, properties, body, timeout) {

method

the request method for the url connection.

properties

An array of properties for the connection.

body

If non-empty, the body to be written to the output stream of the connection.

timeout

If specified, the connect and read timeout in milliseconds.

Source:

(inner) readURL(url, timeout)

Synchronously read a URL.

Parameters:
Name Type Description
url

The url.

timeout

The timeout in milliseconds

Source: