JWM <
jwmw...@gmail.com> wrote:
(snip, I wrote)
>> For the cases mixing descriptors and text closely, it takes a
>> lot less writing. Well, with non-advancing I/O Fortran gets a
>> little closer, but:
>> write(*,1) (A(I),I=1,10)
>> 1 format('A=(',F10.3,9(', ',F10.3),')')
(snip)
>> and note that the Fortran version works only for a constant array
>> size, where the C version is variable (as long as it fits on
>> one line).
> Interesting choice of words. The following should work just fine,
> regardless of the size of the array (as long as it fits on one
> line, of course):
> write (*,'("A=(",*(F10.3,:,", "))', ADVANCE = 'NO')
> write (*,'(")")')
> Even the old way (i.e., using a huge number instead of * )
> should work.
Yes, that is why I mentioned non-advancing.
The huge number works fine, as long as you don't need to add
text after the last item, like the close parenthesis.
With the natually non-advancing C output, I find it naturally
easier to use multiple output statements. That is, I think of the
problem as separate operations, in a way that I don't for Fortran
WRITE.
Well, I think that goes back to PL/I, which I started learning not
long after I started Fortran. PL/I formatted output is STREAM,
naturally non-advancing. Unformatted (binary) output is RECORD,
(using whatever record marks the file system uses).
It is interesting that PL/I STREAM was developed on a system where
the underlying file system is record oriented. It is a little more
obvious on C/unix with a character oriented file system.
-- glen