- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page