Execution Modes

Execution Modes

Inq can be invoked as a client (handles GUI), as a server (to which several clients connect) or interactively, reading an input stream to verify scripts or show demonstrations. There is also a client to load scripts into a server.

A generic launcher command, inq, takes the following arguments:

inq [-server|-client|-load] <args...>
-server
Starts an Inq server. By default, the server will listen on port 6556 for connections from Inq clients made using the native speakinq:// protocol.
-client
Starts the Inq GUI client. Server login parameters can be entered at the login window or supplied on the command line.
-load
Runs the client utility to load scripts into the server. Server login parameters are entered on the command line.

If none of -server, -client or -load are specified then interactive mode is assumed.

This section introduces each Inq mode. We will revisit them when describing how to run the example applications.

Invoking The Server

The server is started as follows:

>inq -server
Inq Server
Copyright (c) InqWell Ltd 2002-2008
Java Compiler Compiler Version 3.2 Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
DeadlockScanner Started
Server Started
speakinq Socket Listener Started on port 6556

The server requires the system property inq.home to be set so that it can verify administrator login requests (see section on server administration). The launcher establishes this as the value of the INQHOME environment variable.

The Inq server starts a listener process and awaits connections from clients. The speakinq protocol uses plain sockets and a listener is always started. If the JavaTM system properties of javax.net.ssl.keyStore (and if necessary javax.net.ssl.keyStorePassword) are set the server starts a SSL listener on the default port of 6557. Clients connect to this port using URLs of the form speakinqs://.

When launching the server, the following command line arguments are available

-speakinqport <port-number>
overrides the default plain socket port of 6556 to the specified <port-number>
-speakinqsport <port-number>
overrides the default SSL socket port of 6557 to the specified <port-number>

Invoking The GUI Client

The Inq GUI client connects to a server instance from which it downloads the scripts that define it. The following invocation brings up the login window:

>inq -client
Inq Client
Copyright (c) InqWell Ltd 2002-2008
Java Compiler Compiler Version 3.2 Copyright (c) 2003 Sun Microsystems, Inc. All Rights Reserved.
JDateChooser Copyright (c) Kai Toedter 1999 - 2006
GUI Client Login Window

When connecting to a server, as well as the URL of the server to connect to, the client supplies a username, password and package. If these are supplied as command line arguments then the login window is not shown.

As we will see later, functions and services written in Inq script are organised into packages. A package is a sub-division of the global name space and can be used to host several different applications in the same Inq server.

As login attempts are made the client maintains a list of the usernames, packages and server URLs used for easy selection. If an incomplete set of command line arguments are specified then these are loaded into the GUI before the login window is shown, leaving the user to enter those that remain. Use the following arguments as required:

-u <username>

-p <password>

-package <package specification>

-serverHost <server url>

Loading Server Scripts

An Inq environment, whether client or server, can do nothing until the scripts that define its operation have been loaded. The GUI client obtains its scripts from the server it is connected to. The server must be loaded using a client utility provided for this purpose. This is similar to loading a database server with tables and stored procedures.

Here is an example invocation of Inq to do this:

inq -load \
    -serverHost speakinq://localhost \
    -package system \
    -url file:/C:/inqwell/dev/wwwroot/inq/auth/inqBoot.inq \
    -u admin \
    -p inqwell

This command instructs the server at localhost to run the script at the URL file:/C:/inqwell/dev/wwwroot/inq/auth/inqBoot.inq, which is resolved by the server.

Running Interactive Scripts

Inq applications comprise a configured server to which several clients connect to use shared services and cooperate for data. However, it is is possible to run scripts interactively. This is useful for testing script fragments or showing GUI demonstrations.

Inq reads from standard input, or from the URL specified by the -in argument. If you have downloaded the Inq distribution and assuming you are in the examples directory, try the centigrade-to-fahrenheit example coded in C2F.inq.

The command inq -in C2F.inq will show the window below:

C2F Window

Try moving the sliders and entering values into the text fields.

The -in argument requires a URL. If the URL is relative it is resolved with respect to the current working directory. Absolute file paths on the local host require a URL specifying the file:// protocol. For example, on a Windows system the path C:\inqwell\doc\src\documentation\content\xdocs\primer\examples\array.inq will resolve correctly with the url of file:///C:/inqwell\doc\src\documentation\content\xdocs\primer\examples\array.inq

Every Inq statement has a return value (although this can be null). When running scripts interactively, the -show argument writes the value of each statement to stdout. At a tty prompt, enter the following text (the results are interspersed and shown in bold):

>inq -show
array a = (2.3, 1, 0.5, 6);
[2.3, 1, 0.5, 6]
sort(a, $this);
[0.5, 1, 2.3, 6]
<EOF>
Inq done

Note
<EOF> means the platform-specific end-of-file character, ^D on Unix and ^Z CR/LF for Windows.

This small example also illustrates how, in general, Inq manipulates data nodes without regard for what specific type they are. The literal values 2.3 and 0.5 are of type float whereas 1 and 6 are ints, however they can be sorted regardless of the heterogeneity of the array.