Jump to content

DOS screen formatting via ansi.sys


Recommended Posts

G'day, folks:D

I've been coaxed out of retirement to "modernise" some Fortran programs I wrote last milennium; namely Fortran main program calling C/C++ functions. The modernising was accomplished, using Silverfrost's FTN95 suite. Problem is, when the compiled .exe file was run in the DOS ( command.com ) window the screen-formatting sequences are being ignored. These sequences are used to accomplish things like screen clearing and cursor positioning and are driven via ansi.sys

I've checked that command.com is initialising via autoexec.nt and config.nt where the only active part of config.nt is as follows:


device=%SystemRoot%\System32\ansi.sys
device=%SystemRoot%\system32\himem.sys
files=40
dos=high, umb

To simplify the problem of getting ansi.sys to do the right thing I wrote a short test program in Fortran. It is meant to clear the screen by emitting the four-character sequence <esc>[2J where <esc> is the ASCII character decimal 27. All that happened (appeared on the screen) was a left-pointing arrow (presumably to represent the escape character) followed by '[2J'. The Fortran code appears below, and I've placed the .exe file at http://www.kurrattan.net/exhibits/testesc.exe


character esc*1
C
esc = char(27)
C
pause'All this text should be cleared when enter ''go''.'
write(*,21) esc
21 format(1x,a1,'[2J')
pause'Screen should be clear.'
stop
end

Any suggestions that will get ansi.sys to do the right thing will be gratefully implemented. I presume that my ansi.sys is up to the job; it came with my Windows XP Home edition.

Eric Carwardine, in Perth, Western Australia

Link to comment
Share on other sites

Welcome to the Windows Forum.

I don't know if we have anyone here who knows (or remembers) these low-level screen formatting commands. I certainly don't (I have done low-level screen formatting on IBM 3270 devices on VTAM level, but never on DOS).

But I have read up a bit on it (http://en.wikipedia.org/wiki/ANSI.SYS, http://en.wikipedia.org/wiki/ANSI_escape_sequence), and from a first glance you seem to be doing the right thing. (Although I am not sure if splitting the CSI into two output commands is actually correct.)

Hopefully someone with more practical experience will comment on your post. I am moving this topic to the Programming section, where it may stand out a bit better.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy