CR/LF Control With WRITEs to Console 
Author Message
 CR/LF Control With WRITEs to Console

All,

I'm sure this may have been answered before but I can't find any
reference to it so...

When you do a WRITE within a Do Loop to the console screen such as:

Do IJK=1,10
  WRITE(*,*) 'Loop Count = ', IJK
ENDDO

It will write a new line on the screen for every write.  How can it be
formatted so the writes will stay on the same line & just show the IJK
count incrimenting?

Thanks in advance,
Jeff Krob



Sat, 28 Nov 2009 03:41:06 GMT  
 CR/LF Control With WRITEs to Console

Quote:
>All,

>I'm sure this may have been answered before but I can't find any
>reference to it so...

>When you do a WRITE within a Do Loop to the console screen such as:

>Do IJK=1,10
>  WRITE(*,*) 'Loop Count = ', IJK
>ENDDO

>It will write a new line on the screen for every write.  How can it be
>formatted so the writes will stay on the same line & just show the IJK
>count incrimenting?

>Thanks in advance,
>Jeff Krob

That prob. depends on your compiler, operating system etc.
and maybe it's not possible ... but you could try
carriage control '+'
 E.g. write(*,*)'+ ijk=',ijk
 or write(*,'(''+ ijk='',i3)')ijk

You may also have to fiddle with file attribute switches0
e.g. sequential, access ...etc.
   That is - it has to be pretty important !

For a DOS screen you can poke it right where you want by
but you *really* have to need it before you get into that.

Chris



Fri, 27 Nov 2009 22:04:50 GMT  
 CR/LF Control With WRITEs to Console

Quote:

> >All,

> >I'm sure this may have been answered before but I can't find any
> >reference to it so...

> >When you do a WRITE within a Do Loop to the console screen such as:

> >Do IJK=1,10
> >  WRITE(*,*) 'Loop Count = ', IJK
> >ENDDO

> >It will write a new line on the screen for every write.  How can it be
> >formatted so the writes will stay on the same line & just show the IJK
> >count incrimenting?

> >Thanks in advance,
> >Jeff Krob

> That prob. depends on your compiler, operating system etc.
> and maybe it's not possible ... but you could try
> carriage control '+'
>  E.g. write(*,*)'+ ijk=',ijk
>  or write(*,'(''+ ijk='',i3)')ijk

> You may also have to fiddle with file attribute switches0
> e.g. sequential, access ...etc.
>    That is - it has to be pretty important !

> For a DOS screen you can poke it right where you want by
> but you *really* have to need it before you get into that.

> Chris

Chris,

Thanks for the help but they did not work.  BTW - My compiler is CVF
6.3
Any other ideas???

Jeff



Sat, 28 Nov 2009 04:44:38 GMT  
 CR/LF Control With WRITEs to Console

Quote:
> All,

> I'm sure this may have been answered before but I can't find any
> reference to it so...

> When you do a WRITE within a Do Loop to the console screen such as:

> Do IJK=1,10
>   WRITE(*,*) 'Loop Count = ', IJK
> ENDDO

> It will write a new line on the screen for every write.  How can it be
> formatted so the writes will stay on the same line & just show the IJK
> count incrimenting?

> Thanks in advance,
> Jeff Krob

Does not appear to be possible with CVF.  Specifying advance='no'
suppresses flushing to the screen.  Using extensions "$" in the format
is closer, but you can't tab back to column 1 using "T" format.  The
closest I could get was:

Do IJK=1,10

  WRITE(6,'(a,i0)')'Loop Count = ', IJK
  call sleepqq(500)

  call systemqq('cls')

ENDDO

Looks like what you want, but of course the screen is being completely
cleared between writes and that may or may not be what you want.



Sat, 28 Nov 2009 04:44:46 GMT  
 CR/LF Control With WRITEs to Console

Quote:



>>> All,
>>> I'm sure this may have been answered before but I can't find any
>>> reference to it so...
>>> When you do a WRITE within a Do Loop to the console screen such as:
>>> Do IJK=1,10
>>>  WRITE(*,*) 'Loop Count = ', IJK
>>> ENDDO
>>> It will write a new line on the screen for every write.  How can it be
>>> formatted so the writes will stay on the same line & just show the IJK
>>> count incrimenting?
>>> Thanks in advance,
>>> Jeff Krob
>> That prob. depends on your compiler, operating system etc.
>> and maybe it's not possible ... but you could try
>> carriage control '+'
>>  E.g. write(*,*)'+ ijk=',ijk
>>  or write(*,'(''+ ijk='',i3)')ijk

>> You may also have to fiddle with file attribute switches0
>> e.g. sequential, access ...etc.
>>    That is - it has to be pretty important !

>> For a DOS screen you can poke it right where you want by
>> but you *really* have to need it before you get into that.

>> Chris

> Chris,

> Thanks for the help but they did not work.  BTW - My compiler is CVF
> 6.3

For CVF and some others, an extension is to use "$" or "\" as a format
specifier to suppress CR/LF in interactive output.  It's documented
under FORMAT specifiers.

--



Sat, 28 Nov 2009 05:01:18 GMT  
 CR/LF Control With WRITEs to Console

Quote:



> >>> All,
> >>> I'm sure this may have been answered before but I can't find any
> >>> reference to it so...
> >>> When you do a WRITE within a Do Loop to the console screen such as:
> >>> Do IJK=1,10
> >>>  WRITE(*,*) 'Loop Count = ', IJK
> >>> ENDDO
> >>> It will write a new line on the screen for every write.  How can it be
> >>> formatted so the writes will stay on the same line & just show the IJK
> >>> count incrimenting?
> >>> Thanks in advance,
> >>> Jeff Krob
> >> That prob. depends on your compiler, operating system etc.
> >> and maybe it's not possible ... but you could try
> >> carriage control '+'
> >>  E.g. write(*,*)'+ ijk=',ijk
> >>  or write(*,'(''+ ijk='',i3)')ijk

> >> You may also have to fiddle with file attribute switches0
> >> e.g. sequential, access ...etc.
> >>    That is - it has to be pretty important !

> >> For a DOS screen you can poke it right where you want by
> >> but you *really* have to need it before you get into that.

> >> Chris

> > Chris,

> > Thanks for the help but they did not work.  BTW - My compiler is CVF
> > 6.3

> For CVF and some others, an extension is to use "$" or "\" as a format
> specifier to suppress CR/LF in interactive output.  It's documented
> under FORMAT specifiers.

I tried "$" and "\" (interchangeable), but there was no way to
reposition the cursor back to beginning of row.  Next write began
immediately at end of previous write.  Tried T1 format but that was
ignored.

- Show quoted text -

Quote:

> --



Sat, 28 Nov 2009 05:10:02 GMT  
 CR/LF Control With WRITEs to Console

Quote:


>> All,

>> I'm sure this may have been answered before but I can't find any
>> reference to it so...

>> When you do a WRITE within a Do Loop to the console screen such as:

>> Do IJK=1,10
>>   WRITE(*,*) 'Loop Count = ', IJK
>> ENDDO

>> It will write a new line on the screen for every write.  How can it be
>> formatted so the writes will stay on the same line & just show the IJK
>> count incrimenting?

>> Thanks in advance,
>> Jeff Krob

> Does not appear to be possible with CVF.  ...

Didn't see the desire for the overwrite previously.

In CVF, the way is to use the Win32 API SetConsoleCursorPosition.  It's
documented in the help files on console applications and I think there's
a sample project...

--



Sat, 28 Nov 2009 05:21:21 GMT  
 CR/LF Control With WRITEs to Console
...

Quote:

> I tried "$" and "\" (interchangeable), but there was no way to
> reposition the cursor back to beginning of row.  ...

See my other response re: SetConsoleCursorPosition()

--



Sat, 28 Nov 2009 05:28:44 GMT  
 CR/LF Control With WRITEs to Console

Quote:

> I tried "$" and "\" (interchangeable), but there was no way to
> reposition the cursor back to beginning of row.  Next write began
> immediately at end of previous write.  Tried T1 format but that was
> ignored.

Substitute "interpreted differently than you expected" for "ignored".
While both $ and \ are nonstandard edit descriptors and thus the
standard isn't definitive on them, still one can get some guidance from
it. Those edit descriptors are related to the standard advance='no'. I
would strongly expect their implementation to be simillar.

With advance='no', the T edit descriptor specifies a position relative
to the left tab limit - *NOT* relative to the beginning of the record.
The left tab limit is set to the current position with each write.
Without advance='no' (or nonstandard equivalents), the distinction isn't
obvious.

I'd give good odds that the T1 is not ignored, but is instead
interpreted as being relative to the left tab limit, which makes it
useless for this purpose. If you try a T other than T1, or if you put
some other output befoew the T1, but in the same write, it would
presumably be more obvious that it wasn't being ignored. But that
doesn't make it any more useful for this purpose.

Yes, this subject has been discussed many times here before. It doesn't
surprise me to see it asked again, but it slightly surprises me to see
the "regulars" rehash the same things that don't work.

There isn't a good simple portable answer. It is too dependent on
environmental details. One can fiddle with explicitly writing control
characters to the output, but that depends on the details of the
interpretation of control characters, which varies depending on the
environment. There was a time when using ANSI terminal escape sequences
was at least reasonably portable. It still is probably a decent option,
but you do have to then worry about whether particular environments
support the ANSI sequences or not. For example, I don't think they are
supported by default in some Windows envirionments, though there are
ways to make it work, which probably vary from version to version of
Windows.

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



Sat, 28 Nov 2009 05:35:01 GMT  
 CR/LF Control With WRITEs to Console

Quote:
tornado Jeff writes:
> Thanks for the help but they did not work.  BTW - My compiler is CVF
> 6.3
> Any other ideas???

I know it can be done with CVF 6.6, and I'd be surprised if 6.3 couldn't
do it.  Others have shown how to suppress the line feed, but are having
trouble repositioning the cursor back to the left margin.  I simply
declare:

      CHARACTER*1 CR
      CR = CHAR(13)

and then include CR as the first item in the output list, obviously
with the A1 format edit descriptor.  That forces the carriage return
(hence the name of the variable).



Sat, 28 Nov 2009 05:44:41 GMT  
 CR/LF Control With WRITEs to Console
The standard way to elimintae the output of a cr-lf in formmated
output is to use the backslash '\' in the format statement, whenever
you need to continue on the same line for the NEXT output (not this
one). CVF supports this, because I use it.

I prefer to write BINARY UNFORMATTED text without format statements,
for any program-designed page writing (for example when writing a WORD-
readable document by outputting RTF code).



Sat, 28 Nov 2009 08:09:04 GMT  
 CR/LF Control With WRITEs to Console
Quote:



>>> All,

>>> I'm sure this may have been answered before but I can't find any
>>> reference to it so...

>>> When you do a WRITE within a Do Loop to the console screen such as:

>>> Do IJK=1,10
>>>   WRITE(*,*) 'Loop Count = ', IJK
>>> ENDDO

>>> It will write a new line on the screen for every write.  How can it be
>>> formatted so the writes will stay on the same line & just show the IJK
>>> count incrimenting?

>>> Thanks in advance,
>>> Jeff Krob

>> Does not appear to be possible with CVF.  ...

> Didn't see the desire for the overwrite previously.

> In CVF, the way is to use the Win32 API SetConsoleCursorPosition.  It's
> documented in the help files on console applications and I think there's
> a sample project...

I was trying to avoid the API answer.  I also have a free library called
EZCONSOLE (for CVF and MS FPS4) that makes it very easy as well.

Quote:
> --

--

Gary Scott

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



Sat, 28 Nov 2009 08:29:52 GMT  
 CR/LF Control With WRITEs to Console

Quote:


>>I tried "$" and "\" (interchangeable), but there was no way to
>>reposition the cursor back to beginning of row.  Next write began
>>immediately at end of previous write.  Tried T1 format but that was
>>ignored.

> Substitute "interpreted differently than you expected" for "ignored".
> While both $ and \ are nonstandard edit descriptors and thus the
> standard isn't definitive on them, still one can get some guidance from
> it. Those edit descriptors are related to the standard advance='no'. I
> would strongly expect their implementation to be simillar.

Yes, I did try other tab values (T100) and the effect was as anticipated
(relative to the current cursor position following the previous write).
  I meant ignored in the sense that it didn't reposition the cursor
relative to the physical record (of the terminal).  I guess maybe
conceptually, it was positioning to position 1 relative to the "logical"
record (in terminlogy that I'm familiar with) which was about to be
written.  I just don't like the resulting behavior in this case.

Quote:

> With advance='no', the T edit descriptor specifies a position relative
> to the left tab limit - *NOT* relative to the beginning of the record.
> The left tab limit is set to the current position with each write.
> Without advance='no' (or nonstandard equivalents), the distinction isn't
> obvious.

> I'd give good odds that the T1 is not ignored, but is instead
> interpreted as being relative to the left tab limit, which makes it
> useless for this purpose. If you try a T other than T1, or if you put
> some other output befoew the T1, but in the same write, it would
> presumably be more obvious that it wasn't being ignored. But that
> doesn't make it any more useful for this purpose.

> Yes, this subject has been discussed many times here before. It doesn't
> surprise me to see it asked again, but it slightly surprises me to see
> the "regulars" rehash the same things that don't work.

> There isn't a good simple portable answer. It is too dependent on
> environmental details. One can fiddle with explicitly writing control
> characters to the output, but that depends on the details of the
> interpretation of control characters, which varies depending on the
> environment. There was a time when using ANSI terminal escape sequences
> was at least reasonably portable. It still is probably a decent option,
> but you do have to then worry about whether particular environments
> support the ANSI sequences or not. For example, I don't think they are
> supported by default in some Windows envirionments, though there are
> ways to make it work, which probably vary from version to version of
> Windows.

--

Gary Scott

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



Sat, 28 Nov 2009 08:34:20 GMT  
 CR/LF Control With WRITEs to Console

Quote:

> I guess maybe
> conceptually, it was positioning to position 1 relative to the "logical"
> record (in terminlogy that I'm familiar with)

I'd avoid using that terminology here. The term "logical record" is used
for different concepts than this one. The term is probably older than I
am, or at least darned close. You will confuse things if you use that
established term for this unrelated thing.

There is only one record involved here. I think that is the point you
are missing. Advance='no' (or the nonstandard $ and \ edit descriptors)
are used to write one record with multiple write statements. The parts
written are not logical records; they are just part of the record. In
fact, the entire record is a logical record in the usual terminology,
though the distinction between logical and physical records is more of a
tape media thing (I did note that it is an old term) than useful for
terminals.

Quote:
> I just don't like the resulting behavior in this case.

That's a different matter. Don't think I'll try to argue why it is good
or bad. Just that's the way it is.

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



Sat, 28 Nov 2009 08:54:20 GMT  
 CR/LF Control With WRITEs to Console

Quote:




>>>> All,

>>>> I'm sure this may have been answered before but I can't find any
>>>> reference to it so...

>>>> When you do a WRITE within a Do Loop to the console screen such as:

>>>> Do IJK=1,10
>>>>   WRITE(*,*) 'Loop Count = ', IJK
>>>> ENDDO

>>>> It will write a new line on the screen for every write.  How can it be
>>>> formatted so the writes will stay on the same line & just show the IJK
>>>> count incrimenting?

>>>> Thanks in advance,
>>>> Jeff Krob

>>> Does not appear to be possible with CVF.  ...

>> Didn't see the desire for the overwrite previously.

>> In CVF, the way is to use the Win32 API SetConsoleCursorPosition.  
>> It's documented in the help files on console applications and I think
>> there's a sample project...

> I was trying to avoid the API answer.  I also have a free library called
> EZCONSOLE (for CVF and MS FPS4) that makes it very easy as well.

Oh, still another constraint!  :)

I was trying to avoid the ASCII CR because I wasn't sure how it might be
interpreted in XP as I couldn't recall whether I had done it since
(finally) ditching NT4 and knowing only superficially I had read of some
things that weren't the same/supported.  I tried a test project and it
does work so that's probably the easiest...

What I tested was

write(*,'('A,I3.3\')) chr13, i

where chr13 is char(13)

Now, have we beat this to death, yet... :)

--



Sat, 28 Nov 2009 09:11:07 GMT  
 
 [ 25 post ]  Go to page: [1] [2]

 Relevant Pages 

1. stripping cr/lf, lf, cr

2. Converting LF to CR LF

3. CR/LF when writing to file

4. replacing cr/lf with <p>

5. VMS GAWK CR/LF Problem

6. How to use CR/LF

7. cr/lf symbol to ASCII File ???

8. Inserting a CR/LF within a string

9. CR-LF in a Memo Field

10. Basic file driver and embeded CR,LF

11. Adding CR+LF when using FWRITE()

12. CR/LF

 

 
Powered by phpBB® Forum Software