Feature request: Protocol variables

Hi Charles,

I find that when I create protocols, I often end up putting placeholder text that I will have to replace multiple times within a protocol. For example, when setting up a particular type of calculation that might happen several times in an experiment, I might have a protocol for setting up a single run and create a subheading with the text “Run XX”. If it is a multi-day protocol, I will include this subheading again on each day, so that if multiple runs are contained within an experiment, I’ll be able to differentiate among them. The issue here is, then I need to go through and edit the XX each time and make sure not to miss any, which I don’t always do without error.

To address this, a feature I would love to see added to Findings is some kind of variable syntax, where the user could add a specific syntax in the protocol and upon adding the protocol to an experiment, could be automatically prompted for the replacement text.

For example, if we were to use Jinja2 template syntax, if I were to include a subheading:

Run {{run_number}}

then upon adding this protocol to an experiment, I could be prompted with a dialog where I could set

run_number = 2

and this value would be inserted in the protocol text wherever {{run_number}} appears. This would effectively mimic a search-and-replace-all functionality. So if I want to enter a terminal command later that looks like:

my_script.py -i run2.txt

I could also write this in the protocol as:

my_script.py -i run{{run_number}}.txt

and have the command generated for the proper input file after only being prompted for the variable once. Findings could scan the text of each protocol for this syntax, or develop its own internal representation of a variable and add it via e.g. an Insert menu item.

We could also take this idea a step further. Perhaps instead of replacing the values in the experiment as plain text, it would be possible to maintain the variable status and keep a record of true experiment-level (or section- or subsection-level) variables, which would be valid within that particular scope. This would require an interface for editing the instance of the variable, which I imagine as a pop-up that would function much like editing a hyperlink in many common email applications. The user might click the variable instance (e.g. the “2” in “Run 2”), then be prompted with a dialog something like:

scope: section
variable: run_number
[convert to plain text] [remove]

So then one could see (or possibly change) the scope of that particular variable, edit which variable should appear there, or convert the variable to plain text or remove the instance entirely by clicking one of the buttons/links at the bottom.

I would find this very useful. Thanks for your consideration!