Labs/Script Layout

From J Wiki
Jump to navigation Jump to search
Labs | Basic Usage | The lab Verb | Script Layout | Lab Commands | Deprecated Commands | Migration

When run as a lab, a script is first parsed into lines of text or code. For this, multi-line texts and code definitions are treated as single lines with embedded linefeeds.

After the script is parsed, then the Labs system will step through the lines by either displaying any text, or executing any code.

Texts

Texts are either a line or sequence of lines beginning NB., or a 0 : 0 definition that is not assigned to a name. The NB. comment indicator is removed.

Note that some lines are script comments, see below, and lines beginning NB.lab... are lab commands.

For example, the following are parsed to the same text line:

NB. Locales Overview
NB. This lab shows how to program with locales.
0 : 0
Locales Overview
This lab shows how to program with locales.
)

Code

Any lines that are not text or lab commands or script comments are treated as code.

Script Comments

There are two forms of comments:

  • any line beginning NB. optionally followed by a blank and then at least three - or = characters
  • any Note block

Examples:

NB. ==========
NB. --- using locales

Note ''
This lab shows how to program with locales.
An application can have several locales.
)