Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Vertical tab in a Windows OS window

Vertical tab in a Windows OS window

Vertical tab in a Windows OS window

I'm running my program from a windowsOS command line window and outputting data and character strings to the same window.

I can write non-advancing output and overwrite the same line via backspaces and writing again (on the same line).

Is it possible, with Fortran, to do an upward vertical tab and overwrite the line above, in a windowsOS command line window?

Thank you.

RE: Vertical tab in a Windows OS window

If you're running XP, it will work on command.com provided ansi.sys is loaded (you need to change config.nt). It doesn't work on cmd.exe. Just make sure that the height of "Window Size" and "Screen buffer size" are the same. Alternatively there are some windows routines to move the cursor to any point on the screen.

RE: Vertical tab in a Windows OS window


Thank you.

Regarding Alternatively there are some windows routines to move the cursor to any point on the screen.

To get me started, what are the names of these windows routines?

Are they in the form of a dll requiring a multilanguage call from Fortran to C++ via interface statements?

RE: Vertical tab in a Windows OS window

Which development system are you using (Silverfrost, Intel, gcc etc)? The routine names vary.

They are normally multilanguage but dev systems like Intel already have the interfaces: all you need to do is call them. I may even be able to give you an example but I have to know what development system you're using.

RE: Vertical tab in a Windows OS window

gcc please, via make files.

RE: Vertical tab in a Windows OS window

Sorry - no makefile. I don't use make on windows. To build


gfortran -g -o cursorg.exe cursorg.f90 
The following puts a message at 40,10 on the screen

CODE --> cursorg.f90

module winconsole
   use, intrinsic:: ISO_C_BINDING
   type, bind(C):: COORD
      integer(C_SHORT) X 
      integer(C_SHORT) Y 
   end type  COORD
   integer (C_LONG), parameter:: STD_INPUT_HANDLE = -10
   integer (C_LONG), parameter:: STD_OUTPUT_HANDLE = -11
   integer (C_LONG), parameter:: STD_ERROR_HANDLE = -12
      function GetStdHandle(nStdHandle) &
         bind (C, name='GetStdHandle')
         !GCC$ attributes dllexport, stdcall :: GetStdHandle
         integer (C_INTPTR_T) GetStdHandle
         integer (C_LONG), value:: nStdHandle
      end function GetStdHandle
      function SetConsoleCursorPosition (hConsoleOutput, dwCursorPosition ) &
         bind (C, name='SetConsoleCursorPosition')
         !GCC$ attributes dllexport, stdcall :: SetConsoleCursorPosition
         integer(C_INT) SetConsoleCursorPosition
         integer(C_INT), value:: hConsoleOutput
         type(COORD), value:: dwCursorPosition
      end function SetConsoleCursorPosition
      function  WriteFile (hConsoleOutput ,lpCharacter ,nLength , lpNumberOfCharsWritten, overlapped ) &
         bind (C, name='WriteFile')
         !GCC$ attributes dllexport, stdcall :: WriteFile
         integer (C_INT) WriteFile
         integer (C_INT), value:: hConsoleOutput
         character(kind=C_CHAR):: lpCharacter(1)
         integer (C_INT), value:: nLength
         integer (C_INT) lpNumberOfCharsWritten
         integer (C_INT) overlapped
      end function WriteFile
      function GetLastError() bind(C, name='GetLastError')
         !GCC$ attributes dllexport, stdcall:: GetLastError
         integer (C_INT) GetLastError
      end function GetLastError
   end interface

end module winconsole

program cursorg
   use, intrinsic :: ISO_C_BINDING
   use winconsole
   integer(C_LONG):: ires, written, leng
   integer(C_INTPTR_T):: hout
   type(COORD) posn
   integer, parameter:: TITLE_LEN = 80
   character(len=TITLE_LEN):: str
   hout = GetStdHandle(STD_OUTPUT_HANDLE)
   if (hout .eq. -1) then
      ires = GetLastError()
      print *, ires
   end if
   posn%x = 40
   posn%y = 10
   str = 'Hey it works'
   ires = SetConsoleCursorPosition(hout, posn)
   leng = len_trim(str)
   ires = WriteFile(hout, str, leng, written, 0)
   read (*,*) str
end program 
This will need kernel32.a which can be obtained from the gcc website. The cmd prompt needs to have the same number of lines in the screen buffer and the window.

RE: Vertical tab in a Windows OS window

Great, thank you, I'll check it out.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login


White Paper - How ESI is Helping Move New Medical Device Product to Market Quicker & More Cost Effic
Early Supplier Involvement has long been a strategy employed by manufacturers to produce innovative products. Now, it almost seems like a necessity. Because decisions made in the design phase can positively affect product quality and costs, this can help add value to OEM bottom lines. This white paper will discuss many facets of ESI, including why it’s so valuable today, what challenges limit the benefits of ESI, how cost is impacted, and more. Download Now

Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close