Automation and the Programming Model
Impulse, Formula, Expo and Nu share one way of putting code in a document and running it, whichever application and whichever language. This page is the overview; the pages under it are the detail.
- Scripts - the Scripts pane and its editor, immediate mode, the object models of the four applications, and running a script from the command line.
- Python - Python Commands,
=PY.NAME()functions and smart objects, and Python environments with pip. - Divooka graphs - visual programs as Functions, Commands and event handlers, and the graph editor.
- Worksheet Functions - Formula functions of your own:
=LUA.NAME(),=CS.NAME(),=PY.NAME()and=DVK.NAME(). - Smart objects - text, tables and pictures in an Impulse document or on an Expo slide whose content comes from a workbook, an expression, a graph or a Data Source.
- Data Sources - live tables from a web API, a SQLite file or an ODBC database, the Data Sources tab, and smart tables formatted by column name.
- Document Parameters and the document session - the values a document shares, and how one graph works on a document in Methodox Office and in Divooka Compute.
- Dependencies - a map of what feeds what in a document.
- Command line and conversion -
mos, the LibreOffice-compatible switches, and converting documents without a window. - Editions - what a document's code may use in the Standard and Compute editions, and finding Divooka Compute.
- Extensions - commands, functions and libraries installed for everyone rather than carried by one document.
- Assistant - an AI assistant that reads and edits documents and writes their automation, in the Start Centre or any MCP client through
mos mcp.
Commands, Functions and event handlers
Every piece of code in a document plays one of three parts.
- A Command changes the document when somebody runs it: a script run from the Scripts pane or the command line, or one of the applications' own menu commands called by name from a script. A Command runs as one transaction: everything it changes is one step in Edit ▸ Undo, and if it fails, everything it changed is rolled back.
- A Function computes a value from its inputs and changes nothing. The application decides when to run it: a worksheet function when the cells it reads change, a smart object when the document is refreshed. Because a Function cannot change the document, recalculating or refreshing it is always safe and gives the same answer for the same inputs.
- An event handler is a Command the document runs when something happens to it: opened, saved, a range changed, the workbook calculated, a parameter changed, smart objects refreshed, a slide show started, advanced or ended. Each handler runs as one transaction; an event its own changes cause is not delivered back to it, undo and redo raise none, and a flood of more than 64 events in a second pauses the handlers. Event handlers are written as Divooka graphs.
Smart objects are Functions, not macros: an Impulse smart object is to a document what a formula is to a cell. Formula's SQL.VIEW, which keeps the answer to an SQL query up to date in the grid, is a Function in the same sense.
Data-source Functions are Functions that fetch from the network or read a file. They fetch only when you ask - Data ▸ Refresh Data (Ctrl+Shift+F5) in Formula, Refresh All (Ctrl+Shift+F9) in Impulse and Expo, or a Command - or when a parameter they read changes, and keep what they fetched in the document, so between refreshes, and in a document opened offline, they answer from the last refresh. A function becomes one by using a fetching node in a graph, or by fetching from a script. A Data Source is the same idea without code: a query to a web API or a database, built in an editor, whose answer is a table.
Languages
| Language | Files | Runs |
|---|---|---|
| Lua | .lua |
In a sandbox: no file or process access of its own (io and os.execute are not there); files and the network are reached only through the host. |
| C# | .csx |
Compiled when it runs, against the same object model, with its types checked. |
| Python | .py |
On SteelPython, which comes with the suite; in the Standard edition under a guard that allows only computing modules. See Python. |
| Divooka graphs | .dvj, the text form of a Divooka .dvk |
Function graphs, Routines and Events graphs, run by Divooka's No-Reflection Interpreter; see Divooka graphs. |
The object models are the same in every language: app, doc and session in Lua and Python, App, Doc and Session in C#, with lowerCamel names in Lua (sheet.usedRange), snake_case in Python (sheet.used_range) and PascalCase in C# (sheet.UsedRange). Positions are counted from 1 in all three. See Scripts.
Where code is kept
Documents carrying code keep their usual extensions, .docx, .xlsx and .pptx; there is no separate macro-enabled format. A workbook's worksheet functions and a document's smart objects are stored inside the file, in a custom XML part Office keeps (see file formats).
Every script and graph is stored inside the document too, with the document's parameters and the data its data-source Functions last fetched: Save in the Scripts pane keeps an edit in the document as an undoable change (written to disk with File ▸ Save), Export writes a plain copy to a file you choose, and a scripts folder beside the document from an earlier release (Report.scripts\) is taken into the document when it opens.
Document Parameters
Functions cannot change the document, so values that several of them share - a principal, a city, a region, a rate - live in Document Parameters: named values, each a number, text, a logical value or a date, stored in the document and edited in the sidebar's Parameters deck (Tools ▸ Parameters). Formulas read them as =PARAM("Region"), scripts and Data Sources as param.Region, and only a Command may set one. Changing a parameter recalculates exactly what reads it.
A parameter is a member of the document, and a Divooka graph reaches the document through a This Document node, which Methodox Office answers with the open document and Divooka Compute with a copy it was sent or a file it opened. So one graph runs the same in both. Document Parameters and the document session explains it in full, with how graphs from earlier releases are brought up to date.
Trust
Opening a document never runs its code. A document carrying code opens with a yellow bar over it reading Scripts disabled and an Enable button; hovering over the bar lists the code the document carries. Until it is enabled, its worksheet functions show #BLOCKED! and its Lua, C#, Python and graph smart objects do not refresh; smart objects that read a workbook, and Data Sources, are data, not code, and refresh either way.
Trust is remembered. Each person has a trust store, trust.json in Methodox Office's settings folder, which records each document they enabled against a hash of everything in it that runs. Opening the same document again needs no second yes; changing one character of its code, in Methodox Office or anywhere else, asks again. Parameters and fetched data are not code and do not count.
Granted access
In the Standard edition, a document's code reaches the network and files only through the host, and only where the person allowed it:
| Language | Calls |
|---|---|
| Lua | host.get(url), host.getJson(url), host.getImage(url), host.readText(path), host.url(...) |
| C# | Host.Get, Host.GetJson, Host.GetImage, Host.ReadText, Host.Url |
| Python | The same calls, in snake_case: host.get_json(url) |
| Divooka graph | HTTP Get, HTTP Get Bytes and Read Text File nodes |
| Data Source | Its web API, SQLite file or ODBC connection |

When code or a Data Source asks for something it has not been granted, an orange bar says what, such as Needs GET api.open-meteo.com or Needs Connect Sales.db, with an Allow button. Enable and Allow carry on with what was waiting: a parameter changed while scripts were disabled takes effect once you press Enable, and each Allow lets the refresh go on and ask for the next thing it needs, so a document that needs several grants asks for them one after another without being opened again. Each website, file and database is allowed per document and remembered in the trust store against the document's code hash, like enabling. When something fails, a red bar says what; when the failure is at a graph's node, its button opens the graph with the node selected.
Two editions
What a trusted document's code may use is set by the edition of Methodox Office: Methodox Office (Standard) runs Lua, C#, guarded Python and graphs made of the audited Office nodes and the Divooka standard library's pure routines, with the network and files reached only through the host's granted calls; Methodox Office + Divooka Compute also runs graphs using the Divooka packages installed beside it, and full Python with the packages of the document's Python environment, in full trust once the person trusts the document. Neither includes Divooka Compute itself, which Office finds when it is installed. See Editions.
A graph that uses a node its edition does not allow is refused before anything runs, and the message names the graph and the node.
SQL
Formula's SQL Workbench, SQL.VIEW and SQL.STORED query a workbook's tables, named ranges and sheets with SQLite's SQL, read-only; SQL.STORED runs a query saved in the workbench by name, with values bound to its parameters. A .NET program hosting the engine reaches the same layer through WorkbookSql.Query(workbook, sql) in the Divooka.Office.Calc.Sql package. Scripts do not have it in their object model yet. To query a database outside the workbook, use a Data Source.
Extensions
Code that should be there for every document, rather than carried by one, is an extension: commands on Tools ▸ Extensions, worksheet functions and script libraries, installed from the Start Centre and run under the same rules as a document's code.
Without a window
Every application runs scripts, converts documents and prints to PDF from the command line without opening a window, and mos does all of it for the whole suite. See Command line and conversion.
Examples
The suite's Examples\Automation folder has the scripts and documents used on these pages: the sample scripts in Lua, C# and Python, the smart report bound to a budget workbook, a loan calculator and loan letter driven by graphs and parameters, a workbook with event handlers and the graph editor's workbook. The Weather Report, the Market Dashboard, the Data Sources workbook and Nu's circle of triangles are in their applications' folders. See Examples.