Back in the mists of time, in FORTRAN IV and 77, I used to do things like that using ENCODE and DECODE which provided normal fortran formatted output to character variables like your "name" variable instead of writing to file/printer/etc.
No doubt these have long been replaced by more modern techniques.