Guides/Window Driver/Command Syntax

From J Wiki
Jump to: navigation, search

This description is intended for the final J804 release. Earlier versions differ in their treatment of binary data.

The Window Driver wd takes a string right argument and returns a result in one of the forms:

  • empty (i.0 0)
  • string
  • 2 column matrix of boxed strings

The argument to wd is 0 or more statements delimited by semicolons.

A statement is a command (always a single word) followed by 0 or more parameters.

wd Parameters

If there is more than one parameter in the wd statement, then they need to be separated out from the parameter string.

In the following description:

  • SOH is 1{a. and DEL is 127{a.
  • LF means either LF by itself or CRLF
  • the term delimited parameter means a part of the parameter string that is enclosed either in " (double quotes) or in DEL characters, for example:
'"hello world"'
DEL,'hello world',DEL
  • the term standard parsing is where the parameter string is split up into delimited parameters, and otherwise parameters are separated by one or more space or TAB characters.

Parsing

There are several ways to indicate separate wd parameters. The order of parsing is as follows:

1. If the string contains a * that is not in a delimited parameter and does not follow a SOH or LF character, then this starts a parameter at the next character which runs to the end of the string. The preceding string is subject to standard parsing. For example:

  'one *two three four'

is parsed as:

┌───┬──────────────┐
│one│two three four│
└───┴──────────────┘

Note that this method allows the remaining parameter to be an arbitrary binary string, and is the only such method. For example, a binary string with the complete alphabet may be sent in the websocket command as:

  wd 'ws sendb socket *Alphabet: ',a.

2. Otherwise, if the string contains SOH then this separates parameters, e.g.

   'one',SOH,'two three',SOH,'four'

is parsed as:

┌───┬─────────┬────┐
│one│two three│four│
└───┴─────────┴────┘

3. Otherwise, if the string contains a LF character that is not in a delimited parameter, then this also separates parameters, e.g.

   'one',LF,'two three',LF,'four'

is parsed as:

┌───┬─────────┬────┐
│one│two three│four│
└───┴─────────┴────┘

If there is no such LF, then any other LF characters are treated as normal characters, not separators.

4. Otherwise, the string is subject to standard parsing. The delimiter characters of delimited parameters are removed. For example:

  'one  "two three"',TAB,' four'

is parsed as:

┌───┬─────────┬────┐
│one│two three│four│
└───┴─────────┴────┘

Note that trailing white space is treated as a parameter:

  'one  "two three"',TAB,' four '

is parsed as:

┌───┬─────────┬────┬┐
│one│two three│four││
└───┴─────────┴────┴┘