I wish to change the screen text colours (in DOS mode) by sending the appropriate escape sequences to ANSI.SYS. I have done this successfully with other Fortran compilers but I cannot get it to work with FTN95. What happens is that the escape sequence appears on the screen (which it shouldn't) and the text colour remains white. Thus it seems, in effect, that nothing reaches ANSI.SYS. I also wish to send the escape sequence to clear the screen. I haven't tried this yet but I suspect that this won't work either. Any suggestions would be much appreciatd!
Changing screen text colours
Richard
Try the following format which I used to use in DOS mode (many years ago!):-
CHARACTER*9 F
COMMON /TEK/ISEQ(120)
F='( A1,$)'
WRITE(F(2:4),'(I3)')NCHAR
WRITE(6,F)(CHAR(ISEQ(I)),I=1,NCHAR)
Where ISEQ contained the character index numbers (= ICHAR(character) ) and NCHAR was the number of characters to send.
I hope it works.
John
Here is some undocumented stuff that may be useful....
PROGRAM colours CALL SET_CONSOLE_COLOUR@(7) CALL CONSOLE_WRITE@('7 ') CALL SET_CONSOLE_COLOUR@(8) CALL CONSOLE_WRITE@('8 ') CALL SET_CONSOLE_COLOUR@(9) CALL CONSOLE_WRITE@('9 ') CALL SET_CONSOLE_COLOUR@(10) CALL CONSOLE_WRITE@('10 ') CALL SET_CONSOLE_COLOUR@(11) CALL CONSOLE_WRITE@('11 ') CALL SET_CONSOLE_COLOUR@(12) CALL CONSOLE_WRITE@('12 ') CALL SET_CONSOLE_COLOUR@(13) CALL CONSOLE_WRITE@('13 ') CALL SET_CONSOLE_COLOUR@(14) CALL CONSOLE_WRITE@('14 ') CALL SET_CONSOLE_COLOUR@(15) CALL CONSOLE_WRITE@('15 ') CALL SET_CONSOLE_BACKGROUND@(9) CALL CONSOLE_WRITE@('OK'//CHAR(10)) CALL GET_CONSOLE_CURSOR_POS@(ix,iy) CALL SET_CONSOLE_CURSOR_POS@(20,iy+1) CALL CONSOLE_WRITE_CHAR@(ICHAR('!')) END
Are you sure that the ANSI.SYS system is loaded? I seem to have great difficulty with this installable device driver in Windows XP, but have had much better luck with a small COM file named ANSI.COM which you run immediately after opening a console window. You can also get it to unload after use, although simply closing the console window unloads it. You run your console application through a batch file such as 'runprog.bat', where the batch file looks like
ansi myprog ansi /u
The copy I have of ANSI.COM is only 3kb long. My copy is dated 1989. It supports all the usual ANSI ESCape codes, and a few that aren't in ANSI.sys. I did a GOOGLE, and after some searching I found it: http://www.pcmag.com/article2/0,1759,1556221,00.asp
There is something similar called NANSI, which is available in SYS and COM versions (http://alumnus.caltech.edu/~dank/nansi/ or maybe http://www.kegel.com/nansi/) and an update to that called NNANSI - I had forgotten about those oddities.
It seems that from Windows ME it has become difficult to impossible to load ANSI.SYS, so I really do suspect that not having ANSI.SYS is at the root of your problems.
Eddie B.
Please note the following alternative to the code that I posted...
PROGRAM colours INTEGER oldColour,SET_CONSOLE_COLOUR@ oldColour = SET_CONSOLE_COLOUR@(7)
Okay Richard
This WILL work !
Any DOS command can be issued from a FTN95 application by calling CISSUE
So to clear the screen of text, do:-
CALL CISSUE('CLS',IFAIL)
IFAIL is returned as zero if the command was successful.
regards John 😃
I have to apologise for misleading information. ANSI.com had enabled me to use ESCape codes in Windows 2000, and I assumed it would work in XP. It doesn't. What does work, however, are the old text screen commands from FTN77, e.g. SCREEN_CLEAR@.
Here is a use of SCREEN_CLEAR@
PROGRAM STUFF
WRITE(6,*) ' To be cleared '
CALL CLEAR_SCREEN@
WRITE(6,*) ' Now I am writing ... '
STOP
END
I just tried it, and you don't see ' To be cleared ', but you do see ' Now I am writing ...'
There is a mention of CLEAR_SCREEN@ in the FTN95 online documentation, but it does read as though this is a Windows function - it probably is as well.
Emboldened by this discovery, I added a call to COUP@ - another old DOS text screen routine - just before the STOP. The precise statement I used was:
CALL COUP@('Some coloured text', 5, 10,10)
Lo and behold, it worked. The parameters are a CHARACTER string to print, the DOS colour index (5 in my case), column and row (10 and 10 respectively, measured in standard way from top left of the screen). The colour index, according to FTN77 documentation, is the 8 least significant bits of an INTEGER. Bits 3,2,1,0 define the foreground colour (0 to 15), bits 6,5,4 the background colour (0 to 7) and bit 7 whether it flashes or not.
The 16 foreground colours are, as in ANSI, 8 colours in standard and 'bright'. The documentation (see later) says that to get the colour index for flashing red (4) text on a green (2) background, the index is set to 1128 + 216 + 4.
The documentation is in Chapter 21, starting on page 163 of the 'Library.pdf' file which used to be online as documentation for FTN77 (I don't know if it is still). COUP@ can't be found in the FTN95 help file - at least, I couldn't find it. If LIBRARY.PDF is no longer available, and Paul doesn't mind, I could send it to you ... some of the other stuff may work as well. It's around 2Mb.
I suppose this is also a definitive answer to your original question - hooray and about time too!
Eddie Bromhead
Richard,
Glad to be of service, and apologies for misleading you originally.
I wonder what else from DBOS FTN77 is still lurking around, undocumented, in FTN95?
Eddie