Software Archive
Read-only legacy content

ansi.sys

hemlock
Beginner
266 Views
I've inherited an old F77 program that relied heavily on ANSI.SYS to perform all kinds of console screen magic. Older executables work fine, but now that I'm porting to Visual Fortran, I'm getting nowhere. The old F77 code has all kinds of bizarre escape sequences for cursor positioning, etc. and apparently they are only understood by ansi.sys. How do I get a new Visual Fortran program to work with ansi.sys? Do I have to include it somehow or add it to my project? I already tried simply adding ansi.sys to my project files and I get the same problems. By the way, everything compiles fine, but when it runs the console window is full of weird characters and the program halts without error/warning. Thanks.
0 Kudos
2 Replies
Intel_C_Intel
Employee
266 Views
I had the same problem converting my old F77 code to F90. There are two solutions. One is to use a .com ansi screen driver such as dgansi.com that came with an old multitasking system called desqview. The .com form of the screen driver can be run from a DOS prompt prior to execution of your program. The escape sequences will then be interpreted correctly.

The second, and better (IMHO), is to rewrite the code using CVF output routines and then recompiling the code as a quickwin application. I have included some of my code below:

 
RECURSIVE SUBROUTINE SCREEN 
  USE DFLIB; USE GEOMC; USE GLOBAL; USE GDAYC; USE SCREENC; USE SURFHE; USE TVDC; USE LOGICC; USE NAMESC 
 
! Compaq Visual FORTRAN 
 
  TYPE (WINDOWCONFIG) MyScreen(NWB) 
  TYPE (RCCOORD)      CurPos 
  LOGICAL             StatusMode 
 
! Type declarations 
 
  INTEGER           :: STAT,   ROWA,   COLA,    ROW                                                                    !SW 10/15/00 
  INTEGER(I2)       :: STATUS, XWIDTH, YHEIGHT 
  INTEGER(I2), SAVE :: ZERO=0, ONE=1,  TWO=2 
  INTEGER,     SAVE :: NLINES=24 
  LOGICAL,     SAVE :: DISTRIBUTED_TRIBS 
  CHARACTER(10)     :: CTIME 
  CHARACTER(12)     :: CDATE 
  CHARACTER(64)     :: TEXT 
RETURN 
 
ENTRY SCREEN_OPEN 
  STAT = AboutBoxQQ ('CE-QUAL-W2 V3.1 - Developed by Tom Cole, WES and Scott Wells, PSU'C)                             !TC 3/9/01 
  WRITE (TEXT(1:49),'(A47,I2)') 'CE-QUAL-W2 V3.1 - Run parameters for waterbody ',JW 
  OPEN  (JW,FILE='user',TITLE=TEXT(1:49)) 
  StatusMode = GetWindowConfig (MyScreen(JW)) 
 
! Distributed tributaries 
 
  DISTRIBUTED_TRIBS = .FALSE. 
  DO JB=1,NBR 
    IF (DIST_TRIBS(JB)) DISTRIBUTED_TRIBS = .TRUE. 
  END DO 
 
! initialize window 
 
  CALL CLEAR_SCREEN 
  CALL DATE_AND_TIME (CDATE,CTIME) 
  XWIDTH  = MyScreen(JW).NumXPixels 
  YHEIGHT = MyScreen(JW).numYPixels 
  STATUS  = Rectangle     ($GBORDER,ZERO,ZERO,XWIDTH,YHEIGHT) 
  STATUS  = FloodFill     (XWIDTH/TWO,YHEIGHT/TWO,ONE) 
  I       = SetBkColorRGB (#FFFFFF) 
  I       = SetTextColor  (ONE) 
 
! Time related variables 
 
  CALL XYLOC   (2,1) 
  CALL OUTTEXT ('Time Parameters') 
  CALL XYLOC   (2,3) 
  CALL OUTTEXT ('[GDAY]   =             ,') 
  CALL XYLOC   (2,4) 
  CALL OUTTEXT ('[JDAY]   =              ') 
  CALL XYLOC   (2,5) 



and here is the xyloc routine:

 
ENTRY XYLOC (COLA,ROWA) 
  CALL SetTextPosition (INT2(ROWA),INT2(COLA),CurPos) 
END SUBROUTINE SCREEN 



Tom

0 Kudos
Steven_L_Intel1
Employee
266 Views
Your old F77 program was a 16-bit DOS executable. Windows NT/2000 doesn't support ANSI.SYS for 32-bit executables - Visual Fortran has nothing to do with it.

We have come up with a library of "screen I/O" routines that may be useful to you. Unpack screenio.zip into your project folder and add the two files to your project. Add USE SCREENIO to the top of routines that want to call the screen routines - read the .f90 file for routine descriptions.

Steve
0 Kudos
Reply