Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

character as variable name

Status
Not open for further replies.

DerSucher

Technical User
Aug 2, 2005
2
DE
Hi,

I want to use a character to work with other variables, something like:

integer ::k=4
CHARACTER (len=100) :: name
name = 'k'
print *, name

-> Output: k
how to get a '4' as output instead of k?
 
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.
 
Use interpretive language instead of that Fortran with its compilers (if you don't want to implement your own run-time dictionary stuff to keep relations between variable names and its memory locations;)...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top