notebook()
notebook(filename)
notebook(filename, 'edit')
tf = notebook(...)
| Parameter | Description |
|---|---|
| filename | a character vector or string scalar: a Notebook document (.nlx) or a Notebook plain-text file (.m). |
| 'edit' | open the document in the Notebook editor instead of running it. |
| Parameter | Description |
|---|---|
| tf | a logical: true when the document ran or opened. |
notebook runs a Notebook document without the editor: it reads the code of each code cell, in order, and evaluates it against the base workspace. Variables created in one cell are visible to the next, as when running the document in the editor.
The native .nlx container (a zip holding the document) and the plain-text .m Notebook format are both supported; an ordinary .m script is run as a single cell.
notebook(filename, 'edit') opens the document in the Notebook editor instead: a tab of the web desktop, or, in the Qt desktop, the Notebook window (one window, one tab per document). edit(filename) does the same for a .nlx file. Figures created by a cell are rendered in the document, not in a figure window.
notebook() without argument opens a new, untitled document in the Notebook editor; the Qt desktop also offers it as the Notebook button of its toolbar and entry of its Window menu. Without a desktop (nelson-cli, nelson-adv-cli) opening the editor raises an error.
% build a minimal Notebook (.nlx) document and run it
d = [tempdir(), createGUID()];
mkdir(d);
fw = fopen([d, '/document.json'], 'wt');
fwrite(fw, '{"blocks":[{"type":"codecell","props":{"code":"a = 40 + 2;"}}]}');
fclose(fw);
nlx = [tempdir(), createGUID(), '.nlx'];
odir = pwd();
cd(d);
zip(nlx, 'document.json');
cd(odir);
notebook(nlx);
a
| Version | Description |
|---|---|
| 2.0.0 | initial version |