Labs/Migration
.ijt files
The earlier version of Labs (pre-J806) used special files with extension .ijt. These files could not be loaded as ordinary scripts.
In the current system, an .ijt file is a script that is specifically intended for use with Labs. The old *.ijt files are still distributed but have been converted to the new format.
Old vs New Labs
The main differences are:
- labs are now ordinary script files, and any script can be run as a lab
- the old labs were parsed into sections and run section by section. The new labs are parsed into text and code lines and run line by line.
- the old Chapters become the new Sections
Internally, the old lab globals are no longer available. Instead the lab definitions are:
- LABFILE is the script name
- LABDEF is the parsed script
while the current state globals are:
- LABPOS is the current position
- LABNDX/LABNOS are indices into LABDEF
- LABNEXT are lines to be run in sequence
Migration
The script File:Migratelab.ijs defines a verb migratelab that will read an old *.ijt file and return text in the new lab format, for example:
load 'migratelab.ijs' migratelab '~addons/labs/labs/core/jtaste2.ijt' NB. Lab: A Taste of J (2) NB. --- First Steps 0 : 0 Look at the following J sentences; can you figure them out? The sentences are shown indented 3 spaces; the result, if any, is shown aligned to the left margin. These simple sentences illustrate some of the core facilities of J, that will be described in this lab. ) tab=: /~ ...
Header definitions
LABTITLE and LABAUTHOR (if given) become the first line of the script:
NB. Lab: {LABTITLE} (by {LABAUTHOR})
LABCOMMENTS if given become a Note:
Note '' {LABCOMMENTS} )
LABDEPENDS and LABWIDTH are ignored.
Sections
A non-empty section header becomes a comment line:
NB. --- {section header}
This is done so that the header can easily be added manually to the following text if required, and otherwise the comment can be deleted.
The rest of the section becomes ordinary lab text and code.
Chapters
The old lab Chapters are now treated as sections, so that the chapter title becomes:
NB.labsection:{chapter title}
Prepare and Script
PREPARE and SCRIPT statements are preserved using NB.labprepare: and NB.labscript: delimiters.