Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Explain these PRINT statements

stevelong_rrx
Beginner
619 Views

Can someone help me understand what these lines of code mean?  (This is an old program using F77 that I inherited.)

      PRINT 99036 , 155 , 50 , 74               ! Erase screen
      PRINT 99036 , 155 , 63 , 51 , 108         ! Set to 80 columns
      PRINT 99036 , 155 , 53 , 59 , 49 , 72     ! Set cursor at beginning of line 5
99036 FORMAT (X,5A1)

The result of this code is the corresponding ASCII characters (except for 155, which should be "") being printed on the screen:

▒2J
▒?3l
▒5;1H

Based on the comments, I gather that these were intended to modify the console display, but I don't understand how.  

What is the meaning of the "5A1" in the format list?

0 Kudos
1 Solution
Arjen_Markus
Honored Contributor I
552 Views

Unless the screen control is somehow essential for the use of the program, it would be far easier to simply remove these statements. An alternative, if you do require this screen control, could be using the curses or ncurses libraries. That requires interfacing with C routines, but at least the hard stuff, getting the terminal to properly listen to these codes, is no longer your responsibility ;).

View solution in original post

0 Kudos
6 Replies
andrew_4619
Honored Contributor III
611 Views

The 5A1 is a format for 5 single text characters ie up to 5 items of 1 character  length.

The Fortran is none standard , printing 50 is printing Achar(50) (acsii 50) ie "2"  achar(74) is "J"

155 is a non printing character. These are "escape sequences" uses by old terminals to do operations like clear screen.

 

See https://en.wikipedia.org/wiki/ANSI_escape_code

 

 

 

 

0 Kudos
stevelong_rrx
Beginner
604 Views

Is there an up-to-date equivalent for a modern terminal (e.g., PuTTY connecting to a RHEL 7 server), or is my best bet to just remove these lines that no longer do what was originally intended?

0 Kudos
JohnNichols
Valued Contributor III
583 Views

Windows has now returned some elements of the ASCII control characters to the console.  I am sure on this forum there are some recent posts on this matter, here is the code from the earlier posts.

0 Kudos
Arjen_Markus
Honored Contributor I
553 Views

Unless the screen control is somehow essential for the use of the program, it would be far easier to simply remove these statements. An alternative, if you do require this screen control, could be using the curses or ncurses libraries. That requires interfacing with C routines, but at least the hard stuff, getting the terminal to properly listen to these codes, is no longer your responsibility ;).

0 Kudos
mecej4
Honored Contributor III
540 Views

You can try using 7-bit ANSI escape sequence codes instead of 8-bit codes. For instance,  instead of the 8-bit character 0x9B (155), you can use the two 7-bit characters, 'Esc',  i.e., 0x1B, and '[', as the CSI (see the WIkipedia article for details).

0 Kudos
JohnNichols
Valued Contributor III
520 Views

@Arjen_Markus  is correct, using these codes is a complete nightmare and makes the coding really difficult to follow, but in 1988 it was the only choice, now you have much better choices.  

0 Kudos
Reply