+ const struct variable **vars = NULL;
+
+ assert (trns != NULL);
+ model = trns->c;
+ assert (model != NULL);
+ assert (model->depvar != NULL);
+ assert (model->resid != NULL);
+
+ vars = xnmalloc (model->n_coeffs, sizeof (*vars));
+ n_vals = (*model->get_vars) (model, vars);
+
+ vals = xnmalloc (n_vals, sizeof (*vals));
+ output = case_data_rw (c, model->resid);
+ assert (output != NULL);
+
+ for (i = 0; i < n_vals; i++)
+ {
+ vals[i] = case_data (c, vars[i]);
+ }
+ obs = case_data (c, model->depvar);
+ output->f = (*model->residual) ((const struct variable **) vars,
+ vals, obs, model, n_vals);
+ free (vals);
+ free (vars);
+ return TRNS_CONTINUE;
+}
+
+/*
+ Returns false if NAME is a duplicate of any existing variable name.
+*/
+static bool
+try_name (const struct dictionary *dict, const char *name)
+{
+ if (dict_lookup_var (dict, name) != NULL)
+ return false;
+
+ return true;
+}
+
+static void
+reg_get_name (const struct dictionary *dict, char name[LONG_NAME_LEN],
+ const char prefix[LONG_NAME_LEN])
+{
+ int i = 1;
+
+ snprintf (name, LONG_NAME_LEN, "%s%d", prefix, i);
+ while (!try_name (dict, name))
+ {
+ i++;
+ snprintf (name, LONG_NAME_LEN, "%s%d", prefix, i);
+ }
+}