I played a little with a script that should just count void cells in a sheet but it makes TreeSheets stop instead.
import std
// Number of the cells which are a single child of their parent
// and have no text or other subcells
var num_cells_void_cells = 0
// Checks whether the current cell has a _single_ empty subcell
def has_empty_child_cell():
var result = false
if ts_num_children() == 1:
ts_goto_child(1)
if ts_get_text() == "" and not ts_num_children():
result = true
// Go back
ts_goto_parent()
return result
// Recursively traverse the tree, counting void cells.
def count_void_cells():
if has_empty_child_cell():
num_cells_void_cells = num_cells_void_cells + 1
else:
for(ts_num_children()) i:
ts_goto_child(i)
count_void_cells()
// count_void_cells always returns the focus to the parent
// cell (see the line below) so we don't need to call ts_goto_parent
// in this cycle
// Activate the parent cell
ts_goto_parent()
// Traverse the children of the root:
for(ts_num_children()) i:
ts_goto_child(i)
count_void_cells()
var msg = "No empty cells found"
if num_cells_void_cells:
msg = "Found " + num_cells_void_cells + " empty cells."
ts_set_status_message(msg)
// =======================================================