- if (index.f == SYSMIS)
- msg (SW, _("When executing COMPUTE: SYSMIS is not a valid value as "
- "an index into vector %s."), t->vec->name);
- else
- msg (SW, _("When executing COMPUTE: %g is not a valid value as "
- "an index into vector %s."), index.f, t->vec->name);
- return -1;
+ double index; /* Index into the vector. */
+ int rindx; /* Rounded index value. */
+ struct variable *vr; /* Variable reference by indexed vector. */
+
+ index = expr_evaluate_num (compute->element, c, case_num);
+ rindx = floor (index + EPSILON);
+ if (index == SYSMIS)
+ {
+ msg (SW, _("When executing COMPUTE: SYSMIS is not a valid "
+ "value as an index into vector %s."),
+ compute->vector->name);
+ return -1;
+ }
+ else if (rindx < 1 || rindx > compute->vector->cnt)
+ {
+ msg (SW, _("When executing COMPUTE: %g is not a valid value as "
+ "an index into vector %s."),
+ index, compute->vector->name);
+ return -1;
+ }
+
+ vr = compute->vector->var[rindx - 1];
+ expr_evaluate_str (compute->rvalue, c, case_num,
+ case_data_rw (c, vr->fv)->s, vr->width);