Re: Conversion from int to char



Ron Ford wrote:
On Fri, 29 Aug 2008 21:43:33 -0700, Richard Maine posted:


Richard Maine <nospam@xxxxxxxxxxxxx> wrote:


Gary Scott <garylscott@xxxxxxxxxxxxx> wrote:


Ron Ford wrote:

What I don't see is a file. By "file," do people mean "whatever internal
variables you used to read the data?"

It's an abstract concept...the character variable is a substitute for a
"file".

And that's really, really how you want to think of it. Because if you
think of it that way, most other things about its usage pretty much
follow (ok, not all of them, but most of the basics). For a very
particular example, it is "obvious" when you want to do an internal read
versus an internal write. If that isn't obvious, then I'd say you aren't
yet really thinking about the character variable as a substitute for a
file. If you don't think of it that way, then you'll be like all the
other people who just try to memorize when to use read versus write, and
who guess wrong pretty much 50% of the time.

I know, following up to myself, but I realize I didn't adequately finish
explaining the thought in answer to Paul.


This is what MR&C has to illustrate this point:

integer::ival(30), key, i
character(30)::buffer
character(6) :: form(3) (/ '(30i1)', '(15i2)', '(10i3)' /)
read (*, '(a30,i1)') buffer, key
read (buffer, form (key)) (ival(i), i=1,30/key)

I don't quite follow execution here. Maybe someone could comment on the
ideas from this thread with this source as reference.

Thus just changing the terminology is not going to help anyone much in
that while they might then be able to find the syntax, they won't be
able to remember how to use it without looking it up every time. Much
better, in my opinion, is to put index entries or whatever for the terms
you think people are more likely to look up and say "see internal I/O".
Yep, you need that kind of cross-referencing to help them find it. But
once they do find it, you want them to think of it as internal I/O
instead of as something like "smagic syntax for converting between
character and numeric".


There's a lot of different io in fortran. I was never particularly good
with io in any syntax. What's more, there's so many options that it's hard
to keep the relevant portion in view. The open statement has a dozen
possible attributes anyways, which isn't bad. It simply takes longer for
the whole gamut to sink in.

My goodness, if you think the open statement is bad, just try deciphering any Win32 API. Talk about a nightmare of confusion.

--

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

If you want to do the impossible, don't hire an expert because he knows it can't be done.

-- Henry Ford
.



Relevant Pages

  • Re: Conversion from int to char
    ... Ron Ford wrote: ... questions I've had since I renewed my commitment to fortran as a syntax. ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: zipcode selection sort in MR&C
    ... Ron Ford wrote: ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: Difference between Intel Visual Fortran and Compaq VF
    ... that has universally changed though (I prefer the 16# syntax anyway)). ... I've always wondered why the standard insists on the z'xxxxxxxx' ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: Killing the task
    ... Ron Ford wrote: ... Can it be done in Fortran using winapi that program will look at the ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: Fortran 2003/2008 features and compiler poll
    ... Ron Ford wrote: ... But you can program your own application with Windowing and GUI features. ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)