private void setFormula(final String var, final String formulaString) {
        final VariableState state = Objects.requireNonNull(get(var));
        state.formulaString = formulaString;
        state.error = null;
        state.state = State.OK;
        state.formula = null;
        state.result = null;
        state.resultAsCharSequence = null;
        try {
            state.formula = Formula.compile(formulaString);
        } catch (FormulaException ce) {
            state.state = State.ERROR;
            state.error = ce.getUserDisplayableErrorMessage();
            state.resultAsCharSequence = ce.getExpressionFormatted();
        }
    }
Calculates a set of all variables which are needed (directly or indirectly) to calculate the given vars
main/src/main/java/cgeo/geocaching/utils/formulas/VariableMap.java