Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fortran text cursor control

Status
Not open for further replies.

bpl1960

Programmer
Feb 2, 2011
4
US
I've just set up Code::Blocks with gfortran on my PC (Win 8.1, 64-bit). I'm trying to write a routine to position the text cursor. I've tried several variations on:

[pre]! Locate does the Windows-API-related work of moving the text cursor.
Subroutine Locate(Row, Col) ! bind(C, name='SetConsoleCursorPosition')
use iso_c_binding
integer, INTENT(IN) :: Row ! On screen, 0-24.
integer, INTENT(IN) :: Col ! On screen, 0-79.

integer :: Coord ! Composite value of row and column.
integer :: HandleForConsole ! From GetStdHandle routine.

integer(c_long) :: GetStdHandle
integer(c_long) :: SetConsoleCursorPosition

Row = Row - 1 ! Convert from Fortran 1-based
Col = Col - 1 ! numbering to C 0-based.

Coord = 65536 * Row + Col ! Jam both values into 1 integer.
HandleForConsole = GetStdHandle(STD_OUTPUT_HANDLE)

Call SetConsoleCursorPosition(HandleForConsole, Coord) ! Go!
End Subroutine Locate[/pre]

Nothing works. The program runs, but the subroutine is ineffective. I could use any suggestions.
 
Cursor addressing only works when the scrollbar is absent. Set the screen buffer size height equal to that of the window size height.
 
I'm sorry, I don't think I was clear. I was writing a console routine, not a Win/GUI program.
 
i have a problem about fortran software. in
27 write(10,*)iter,xr,xl,xu,fxr*fxl.ea
output tell me about this
C:\Users\SUKENDRO\Documents\Courses\latihan_fortran\latihan_false_position\latihan_falsePosition.F95(27) : error 1069 - Terminating decimal point for binary operator token expected but not found
C:\Users\SUKENDRO\Documents\Courses\latihan_fortran\latihan_false_position\latihan_falsePosition.F95(27) : error 52 - Compilation abandoned

what is there any suggestion for me?
 
sukendro,

This thread is about problems with text cursor control in console windows.

But the compiler is complaining about the item "fxr*fxl.ea" in your output list. If fxl is a derived type, the subfield isolation operator is ' % ' in fortran, not ' . '.
 
1. On the console window, right click on the top left C:\ icon
2. A menu will appear - select properties
3. Select the layout tab
4. There are 3 group boxes: Screen buffer size, window size and window position
5. Set the height figure in the screen buffer size to be the same as that of the height of the window size.
6. Click OK - notice that there is no scrollbar on the console window.
7. Now run your program and the cursor addressing should work.


 
sukendro - If you have a problem, start another thread instead of hijacking this one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top