New utility routine GetLocalScalarIndex() reduces common caller boilerplate
(and fixes a bug!)