format_value function

Converts a (possibly compound) value into a string using the format information