×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

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!

*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

(OP)
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

(OP)

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

(OP)
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

CODE

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
   interface       
      function GetStdHandle(nStdHandle) &
         bind (C, name='GetStdHandle')
         import
         !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')
         import
         !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')
         import
         !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')
         import
         !GCC$ attributes dllexport, stdcall:: GetLastError
         integer (C_INT) GetLastError
      end function GetLastError
   end interface

contains
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
      stop
   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

(OP)
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


Resources

Low-Volume Rapid Injection Molding With 3D Printed Molds
Learn methods and guidelines for using stereolithography (SLA) 3D printed molds in the injection molding process to lower costs and lead time. Discover how this hybrid manufacturing process enables on-demand mold fabrication to quickly produce small batches of thermoplastic parts. Download Now
Design for Additive Manufacturing (DfAM)
Examine how the principles of DfAM upend many of the long-standing rules around manufacturability - allowing engineers and designers to place a part’s function at the center of their design considerations. Download Now
Taking Control of Engineering Documents
This ebook covers tips for creating and managing workflows, security best practices and protection of intellectual property, Cloud vs. on-premise software solutions, CAD file management, compliance, 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