- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to print something on the screen and then read something while the cursor is at the same line, how should I do this?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe you can use something like
WRITE(*,'("Give a value =>: ")',ADVANCE='NO')
READ(*,*) value
Robert
WRITE(*,'("Give a value =>: ")',ADVANCE='NO')
READ(*,*) value
Robert
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe you can use something like
WRITE(*,'("Give a value =>: ")',ADVANCE='NO')
READ(*,*) value
Robert
WRITE(*,'("Give a value =>: ")',ADVANCE='NO')
READ(*,*) value
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No, that doesn't work - at least in our implementation. You have to use an extension:
write (*,'($,A)') "Number please: "
read (*,*) number
write (*,*) number, " is your lucky number"
end
There is a feature request in to make the version using non-advancing I/O work as desired here. The standard doesn't require it, but some other implementations do it.
write (*,'($,A)') "Number please: "
read (*,*) number
write (*,*) number, " is your lucky number"
end
There is a feature request in to make the version using non-advancing I/O work as desired here. The standard doesn't require it, but some other implementations do it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I thought it would work with F2003's flush statement (and output_unit from iso_fortran_env),
but it doesn't. The flush statement "flush( output_unit )"causes the message that unit 6 is not
connected.
Regards,
Arjen
but it doesn't. The flush statement "flush( output_unit )"causes the message that unit 6 is not
connected.
Regards,
Arjen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Steve,
I am a little confused by your remark. The "ADVANCE" specifier works fine and is a FORTRAN feature (see Metcalf , par. 9.11, Non-advancing I/O)
Or do I miss the essence of your remark?
Robert
I am a little confused by your remark. The "ADVANCE" specifier works fine and is a FORTRAN feature (see Metcalf , par. 9.11, Non-advancing I/O)
[fortran] PROGRAM adv IMPLICIT none ! REAL :: value ! WRITE(*,'("Enter a value =>: ")', ADVANCE='NO') READ(*,*) value WRITE(*,*) "You give the value:", value ! WRITE(*,'($,A)') "Enter a value =>: " READ(*,*) value WRITE(*,*) "You give the value:", value ! STOP END PROGRAM adv [/fortran]
Or do I miss the essence of your remark?
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Well, no, I made an error. I was confusing this with the issue where people who want to use non-advancing I/O for a progress bar can't get it working on Intel Fortran. You are correct that it works fine for the "prompt" case. Thanks for picking up on that and I apologize for the mistake.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks you both. both methods works fine

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page