Labs/Deprecated Commands

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

There are two deprecated commands, that are still supported to allow old labs to be run:

  • prepare    indicates a prepare code block
  • script    indicates a script block

A Prepare block has code that is run silently, for example to load required scripts or check global values before continuing the lab.

A Script block has code that is appended to global SCRIPT_jlab_ for use by the rest of the lab.

Their use in new labs is deprecated, since it is better that all code be shown explicitly. However, many old labs use Prepare and Script blocks, so they are still supported.

A pair of NB.labprepare: or NB.labscript: lines delimit the Prepare and Script blocks.

For example, the following is parsed into two lines - a Prepare block and a code line:

NB.labprepare:load required scripts and ensure myprintfn is defined
load 'print'
load 'myutils'
ERRORMSG=. 'Unable to load myutils',LF,LF,'Check they are installed'
ERRORMSG assert_jlab_ 3=nameclass <'myprintfn'
NB.labprepare:

myprintfn RES