split out cast and non-cast versions of getValueAsStr