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

setting the cursor position in a console window

jim_cox
Beginner
2,206 Views
In a console window

SETTEXTPOSITION doesnt work

So how is it possible to set (and retrieve) the cursor position?

Thankx

Jim


(Our old code does it by using assembler routines to pass ansi.sys command strings - True)
0 Kudos
1 Solution
Steven_L_Intel1
Employee
2,206 Views
There are Win32 APIs for manipulating a console window and setting the position. See Console Functions In particular, SetConsoleCursorPosition. You'll need to call GetStdHandle first to get a handle to the console.

ANSI.SYS doesn't work in 32-bit Windows.

View solution in original post

0 Kudos
10 Replies
DavidWhite
Valued Contributor II
2,206 Views
Quoting - jim.cox
In a console window

SETTEXTPOSITION doesnt work

So how is it possible to set (and retrieve) the cursor position?

Thankx

Jim


(Our old code does it by using assembler routines to pass ansi.sys command strings - True)

Jim,

this won't work in a simple console window. Have alook at the Graphics Library Routines under the QuickWin section of the documentation to find out more about using these features. You will need to create a TextWindow instead of a console window.

Regards,

David
0 Kudos
jim_cox
Beginner
2,206 Views
Quoting - David White

Jim,

this won't work in a simple console window. Have alook at the Graphics Library Routines under the QuickWin section of the documentation to find out more about using these features. You will need to create a TextWindow instead of a console window.

Regards,

David


Thought that might be the case :(


So how do I include the Quickwin stuff properly into my program?


If in the code I

USE IFQWIN

and later

CALL SETTEXTWINDOW(1,1,24,80)

At linking I get an unresolved external for _SETTEXTWINDOW

Change the Fortran runtime libraries from debug multithreaded to debug quickwin generates a _winMain already defined error as well as _SETTEXTWINDOW and _DIR being unresolved

And adding IFQWIN.LIB to the linker's dependency list creates a whole stack of unresolved externals

(The new progam started life as an SDI code windowing application if that makes any difference)

Cheers

Jim



0 Kudos
Steven_L_Intel1
Employee
2,207 Views
There are Win32 APIs for manipulating a console window and setting the position. See Console Functions In particular, SetConsoleCursorPosition. You'll need to call GetStdHandle first to get a handle to the console.

ANSI.SYS doesn't work in 32-bit Windows.
0 Kudos
jim_cox
Beginner
2,206 Views
There are Win32 APIs for manipulating a console window and setting the position. See Console Functions In particular, SetConsoleCursorPosition. You'll need to call GetStdHandle first to get a handle to the console.

ANSI.SYS doesn't work in 32-bit Windows.


GetStdHandle or GetConsoleWindow? or are they the same given an AllocConsole() ?

> ANSI.SYS doesn't work in 32-bit Windows.

Well, it works fine in an XP command window - but its really really clunky - which is one reason I'm having to rewrite both the frontend and libraries for this particular baby


0 Kudos
Steven_L_Intel1
Employee
2,206 Views

GetConsoleWindow will work. ANSI.SYS works only for 16-bit apps. We got this complaint a LOT with CVF from people moving from DOS.
0 Kudos
jim_cox
Beginner
2,206 Views
Having trouble with the second paramter to the SetConsoleCursorPosition call.

According to the documentation the call looks like

BOOL WINAPI SetConsoleCursorPosition(
HANDLE hConsoleOutput,
COORD dwCursorPosition
);

where a COORD is

typedef struct _COORD { SHORT X; SHORT Y;
} COORD, *PCOORD;


I'm trying a structure that looks like

TYPE COORD
INTEGER(2) X
INTEGER(2) Y
END TYPE

TYPE (COORD) C


but I keep getting

error #6633: The type of the actual argument differs from the type of the dummy argument.

Any thoughts?

0 Kudos
jparsly1
New Contributor I
2,206 Views
Here's a routine I did in CVF that sets the cursor position. Proabably pretty close to what
you'd need in IVF.

subroutine gotoxy(irow,icol)
use dflib
use dfwin
integer fhandle
logical lstat
Type(T_COORD) wpos
fhandle = GetStdHandle(STD_OUTPUT_HANDLE)
wpos.x = icol
wpos.y = irow
lstat = SetConsoleCursorPosition(fhandle, wpos)

return
end
0 Kudos
Steven_L_Intel1
Employee
2,206 Views
You need to use type T_COORD, not a type that "looks like" it.
0 Kudos
jim_cox
Beginner
2,206 Views
You need to use type T_COORD, not a type that "looks like" it.

Thankx, that did the trick :)

Is there a good source for documentation of the ifort view of the winapi interface and the libraries?

Cheers

Jim

0 Kudos
Steven_L_Intel1
Employee
2,206 Views

The sources for the modules are in the compiler's INCLUDE folder.
0 Kudos
Reply