- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
my question is if there is a command and how can i change an integer to the same character??? ie if
character fname and i=5, fname=command(i)='5'
thanx...
ioanna
character fname and i=5, fname=command(i)='5'
thanx...
ioanna
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In most cases, when programmers ask how to convert between character representations of numbers and numeric representations in Fortran, the answer is "internal file I/O", such as internal READ or WRITE. This lets you read from a character variable as if it were a record in a file, or write to a character variable.
In some cases with single characters, you might find the CHAR and ICHAR intrinsics to be useful, but note that these convert between the internal binary representation, so you need to do something like:
i = ichar('5') - ichar('0')
to convert '5' to 5.
Steve
In some cases with single characters, you might find the CHAR and ICHAR intrinsics to be useful, but note that these convert between the internal binary representation, so you need to do something like:
i = ichar('5') - ichar('0')
to convert '5' to 5.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If I understand you correctly, the posted reply did not answer your question -- you wanted to convert from integer TO character, not the other way around. I would like to do the same thing -- did you ever find a function to do that?
Thank you,
Elaine Hale
Thank you,
Elaine Hale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Elaine, welcome to the forum. Please note that the original post was over a year ago.
My response DID answer the question, for both directions. To convert from numeric to character, use internal WRITE. To convert from character to numeric, use internal READ. Both of these topics are discussed in the Language Reference Manual.
Steve
My response DID answer the question, for both directions. To convert from numeric to character, use internal WRITE. To convert from character to numeric, use internal READ. Both of these topics are discussed in the Language Reference Manual.
Steve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Oh -- I see -- I thought the first paragraph of your reply was leading up to the second, but it stands on its own -- sorry!
Elaine
Elaine

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page