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

Control of screen text

john_humble1
Beginner
475 Views

I have a cvf program that requires user input from a DOS screen to be followed by calculated output to the screen. The output echoes the input and then adds further information that needs to be on the same line. Example

MyInput ProgramOutput

The previous VMS version of the program achieved this through screen positioning using escape sequences but I've not foundanything similar in Visual Fortran or its environment. The $ non-advancing formatis ignored in input. My test program

program test_screenresponse
implicit none
integer :: a,b

type '(a)', 'Input a single digit number'
accept '(i1, $)', a
if (a == 1) then
b = 12
else
b = 24
endif
type '(i1, i4)', a, b
end program

produces

1

1 12

while I need it to follow the first '1' with '12' on the first line.

Hope I've made myself clear. Any suggestions anyone?

TIA

John

0 Kudos
6 Replies
jimdempseyatthecove
Honored Contributor III
475 Views

John,

In the IVF compiler documentation use Search and search for

"Displaying Character-Based Text"

You will find a list of IFQWIN functions.

Jim Dempsey

0 Kudos
drgfthomas
Beginner
475 Views

CVF's C:Program FilesMicrosoft Visual StudioDF98SAMPLESISOVAR has the MODULE ISO_VARYING_STRING which you might have a look at. BTW, it also works with IVF so long as you turn off checking for uninitialized variables.

0 Kudos
Steven_L_Intel1
Employee
475 Views
Your VMS program used "ANSI escape sequences" (made popular by the DEC VT100) to set text color and position. Microsoft supported those in 16-bit Windows with an ANSI.SYS driver but dropped support for it with 32-bit applications under Windows NT and later.

Windows has a set of "console output" routines that can do these things, but they are harder to use than just inserting escape sequences.

Gerry, I can't figure out how ISO_VARYING_STRINGS relates to this question.
0 Kudos
john_humble1
Beginner
475 Views

Thank you Jim (and also Gerry). Knowing the right search string to use makes all the difference! I'd not found these functions previously.

John

0 Kudos
Steven_L_Intel1
Employee
475 Views
You say that the $ is ignored, but that's because you put it on the ACCEPT format. $ has meaning for output only. You also have to open the file with CARRIAGECONTROL='FORTRAN'.

Unfortunately, there's no way to eliminate the new line after the user presses Enter. What you CAN do is use a routine such as GETCHARQQ to wait for a single keypress and then continue. Consider the following version of your code:

program test_screenresponse
use ifcore
implicit none
integer :: a,b
character c

open (unit=6, carriagecontrol='fortran',form='formatted')

write (6, '(a)') ' Input a single digit number'
c = getcharqq()
if (c == '1') then
b = 12
else
b = 24
endif
write (6, "('+',a1, i4)") c, b
end program
0 Kudos
drgfthomas
Beginner
475 Views

Steve said:

Gerry, I can't figure out how ISO_VARYING_STRINGS relates to this question.

John stated:

I have a cvf program that requires user input from a DOS screen to be followed by calculated output to the screen. The output echoes the input and then adds further information that needs to be on the same line.

I do this a lot via ISO_VARYING_STRINGS. It's part of modern Fortran and is OS invariant. It works like a charm but YMMV.

0 Kudos
Reply