"Jan van Oosterwijk" <[log in to unmask]> wrote:
...
> At 13:18 18-07-02 -0600, J. Giles wrote as an answer:
>
>
> >Write (<unit>, '(A)') Str
>
> Well this creates 'X' records (X = size(STR) )
> My idea is that A.D. wants all in ONE record.
> As he suggested the following is possible (lot of work ??):
>
> Character(32) :: FMT = "(####A)"
> write(FMT(2:5), "(I4.4)") X
> Write (<unit>, FMT) Str
>
> But with:
> FMT = "(9999A)"
> it works also, supposing you have at least an idea for the
> upper limit of 'X' .
>
> Alternative, maybe more time consuming, use NON advancing output.
Well, as I said before, he probably wanted an answer that actually
worked. Converting the I/O list item to type Character is a better
solution. It's clearer (and, once the function is debugged and known
safe, it can be hidden away in a MODULE or an INCLUDE file that
you put after a CONTAINS statement).
Note that character expressions are already "varying" in the sense
of the varying string concept. It is only when you assign to a variable
that there is any truncation or blank padding. That's why my version
of varying strings doesn't leak even though the published one does.
Mine has no functions or operators that produce a result of type
"varying". Only assignment produces a result of type "varying".
If I remember to deallocate all explicitly declared varying string
variables, I get no leaks.
--
J. Giles
|