136place
WatchMaker Feature Requests All the ideas and discussions
9 votes Vote

User-defined variables/reusable expressions

Currently I often find myself entering the same lengthy expression in several different places. This is tedious and highly error-prone. I suggest the following feature to solve this problem:

User can define variables, either named arbitrarily or with preset names such as {user1} etc., each having an expression. These variables can then be used in other expressions.

Even a klugy solution like creating a layer of type 'user variable' which is invisible but merely serves to generate the user variable would be fine.

Obviously this implies computing the dependency tree of user variables and evaluating them in order when an input changes. Shouldn't be difficult to implement, and the utility in making more complex watch faces easier to create and maintain will be massive.

Alternatively, a similar effect could be achieved by letting us provide a prefix LUA script to run prior to each update. Assuming each layer expression is evaluated in the same LUA interpreter, we could then just set and use ordinary LUA variables. Probably less efficient (whole script has to be evaluated on every update) but perhaps easier to implement.

mbecroft, 27.01.2015, 22:50
Idea status: under consideration

Comments

Marko, 24.06.2015, 11:35
I also have problem seting global variables. All i set in the root "script" section (not layers) is not visable by the layer elements.

Leave a comment