# Overwriting current line with position edit descriptor "T"

**URL:** <https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951>\
**Category:** Help\
**Created:** [July 25, 2025, 4:25pm UTC](https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951 "2025-07-25T16:25:59Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![RonShepard](https://avatars.discourse-cdn.com/v4/letter/r/a3d4f5/32.png) [@RonShepard](https://fortran-lang.discourse.group/u/RonShepard)\
**Post date:** [July 27, 2025, 4:55pm UTC](https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951/21 "2025-07-27T16:55:32Z")

</div>

> [@jwmwalrus](#):
>
> It’s only for (formatted) stream access, though.

There are a couple of things in this discussion that are still unanswered. One is whether it is allowed to change the access type of a file (back and forth between stream and  
sequential), and the other is what happens with the `NEW_LINE('a')` statement when the file is connected with `access='sequential'`. These two issues are important when trying to write portable code, particularly when that code is outside the standard (as with those last two write statements). I think for the first question that it is allowed by the standard to change access, but a compiler is not required to perform this function. If it can perform this function, I don’t think it is required to do so for all connected files, so there may be some files where it can be done by the programmer but others where it cannot. The other question is really about what happens on windows type file systems when the `NEW_LINE('a')` write statement is executed on a` sequential` file. Does it work anyway, does it append everything to a single line, does it generate an error, or what?

Another related question is how to change the access type for the preconnected unit associated with `print fmt` and `write(*,fmt)`. There are some file characteristics that can be modified with an `open()` statement without closing the file, but I don’t think `access=` is one of them, and if you close and reopen `output_unit`, then it loses its association with `print fmt` and `write(*,fmt)`. Without the ability to change the access type, and with unspecified behavior for the default `access='sequential'` case, the use of this feature seems to be nonportable when applied to `output_unit` (i.e. to screen output).

---

<div class="post-metadata">

**Author:** ![urbanjost](https://avatars.discourse-cdn.com/v4/letter/u/0ea827/32.png) [@urbanjost](https://fortran-lang.discourse.group/u/urbanjost)\
**Post date:** [July 27, 2025, 5:53pm UTC](https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951/22 "2025-07-27T17:53:53Z")

</div>

Unfortunately, ACCESS is not a changeable mode. That makes it difficult to write filter programs that often require stream access on stdin and stdout. Unfortunately, it is just easier to call the C I/O procedures than to try to deal with this deficit, as many aspects of getting the name of the actual file preconnected is allowed to be compiler-dependent, so using INQUIRE and trying to CLOSE and OPEN stdin and stdout is not a portable solution. Non-advancing I/O is not the same as stream I/O so reading stdin one byte at a time or writing to stdout one byte at a time using non-advancing I/O will fail with larger files and so on as well. It would be really nice if Fortran addressed this, as binary filters are an essential part of the GNU/Linux and Unix approach of creating filters as tools and creating custom commands by permuting the filter commands, connecting their I/O via pipes.

```plaintext
23 12.5.2 Connection modes
24 Aconnection for formatted input/output has several changeable modes: these are the blank interpretation mode
25 (13.8.7), delimiter mode (13.10.4, 13.11.4.2), sign mode (13.8.4), leading zero mode (13.8.5), decimal edit mode
26 (13.8.9), input/output rounding mode (13.7.2.3.8), pad mode (12.6.4.5.3), and scale factor (13.8.6). A connection
27 for unformatted input/output has no changeable modes.

```

---

<div class="post-metadata">

**Author:** ![sblionel](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/sblionel/32/853_2.png) [@sblionel](https://fortran-lang.discourse.group/u/sblionel)\
**Post date:** [July 27, 2025, 11:45pm UTC](https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951/23 "2025-07-27T23:45:37Z")

</div>

> [@RonShepard](#):
>
> what happens with the `NEW_LINE('a')` statement when the file is connected with `access='sequential'`

`NEW_LINE` is not part of the I/O system and has no knowledge of how a particular unit is connected. If you send the result of a reference to `NEW_LINE` to file connected for sequential access, you’ll get the character with ordinal 10 (typically LF).

As for changeable modes, I wrote about this topic in [Doctor Fortran in “The Modes, They are A-Changin’” - Doctor Fortran](https://stevelionel.com/drfortran/2020/05/25/doctor-fortran-in-the-modes-they-are-a-changin/)

---

<div class="post-metadata">

**Author:** ![jwmwalrus](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/jwmwalrus/32/4483_2.png) [@jwmwalrus](https://fortran-lang.discourse.group/u/jwmwalrus)\
**Post date:** [July 28, 2025, 1:19am UTC](https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951/24 "2025-07-28T01:19:35Z")

</div>

> [@sblionel](#):
>
> If you send the result of a reference to `NEW_LINE` to file connected for sequential access, you’ll get the character with ordinal 10 (typically LF).

It should be added that for sequential access, the records terminator is still (probably) platform-dependent —e.g., `CRLF` for Windows, `LF` for Unix.

The Intel Fortran compilers have a non-standard `RECORDTYPE` specifier to change the default records terminator. Do gfortran|flang|nvfortran have anything similar?

---

<div class="post-metadata">

**Author:** ![sblionel](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/sblionel/32/853_2.png) [@sblionel](https://fortran-lang.discourse.group/u/sblionel)\
**Post date:** [July 28, 2025, 1:27am UTC](https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951/25 "2025-07-28T01:27:53Z")

</div>

Yeah, those originated on VMS, which had a variety of protocols for record separators. I would not recommend trying to propagate them.

---

<div class="post-metadata">

**Author:** ![Knarfnarf](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Knarfnarf](https://fortran-lang.discourse.group/u/Knarfnarf)\
**Post date:** [July 30, 2025, 3:00am UTC](https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951/26 "2025-07-30T03:00:00Z")

</div>

Hello all!

Very good advice here, but I’ll add this;

> **[AnsiModule.txt](https://drive.google.com/file/d/125vtMHQ3KSyDk5k98B3_hXl7Lqo8vZlT/view?usp=drive_link)**
>
> Google Drive file.

That’s a link to an ANSI module that I’ve written for my own text stuff. Just make sure to include it as a use line and on the compiler line BEFORE your program file. There are functions for writing to a specific position, clearing part/all the screen, or changing colors.

Knarfnarf

p.s. rename from .txt to .f90 before trying to compile.

[Previous page](https://fortran-lang.discourse.group/t/overwriting-current-line-with-position-edit-descriptor-t/9951.md?page=1)
