Re: How to convert integers to characters?



hermitian <iamwuxin@xxxxxxxxx> wrote:

But, is there any pre-defined internal functions could be used
directly?

It is a bit hidden in the wrappings of the user-written functions that
Terry showed, but the actual conversion is done by the read and write
statements. I would actually recommend against using Terry's functions
as is because they are unnecessarily nonstandard and compiler dependent.
I'm also a bit puzzled by some of teh complication. In addition to that,
critical parts are missing from the posted code. Those parts are
probably in the non-posted misc.h file, which I can figure out how to
reverse engineer, but that reverse engineering is more work than solving
the originally stated problem from scratch.

Look up internal i/o in any Fortran text. (Someone recently mentioned
here having a Fortran text that didn't cover internal I/O. I don't nkow
whether the text really didn't cover it or the poster just couln't find
it. He never mentioned what text it was. It you do happen to find a
textbook that doesn't cover it, throw that textbook out and tell us what
ne it was.)

Basically, an internal read/write looks just like an "ordinary" one,
except that you substitute a character variable in lace of the unit
number. The read/write is then from/to that character variable.

As a simple example, using your stated problem

character(len=30)::b="123.4"
real::a

read(b,*) a

A reverse conversion would look like

write(b,*) a

No, there isn't a function version provided as part of the language. You
can write your own easily enough as desired. If the language had one, by
the time it had all the cpability of the read/write statements, it would
also be as complicated as they are.

--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
.