bright@Data-IO.COM (Walter Bright) (04/01/89)
I'm looking for a reliable and portable way of determining if ANSI.SYS or an equivalent driver (NANSI.SYS, FANSI.SYS, ANSI.COM, etc) is loaded. It should also work with versions of MSDOS that have ANSI.SYS built in (like the Japanese versions). I checked PC Mag's ANSI.COM clone to see what it did. It checks to see if the string "CON" appears 10 bytes past where interrupt 29h is hooked. This can't be very reliable since ANSI.COM itself doesn't put the CON string in. I seem to recall that in another issue PC Mag published a technique for doing this, but I can't find it (and some of my back issues are missing). My purpose is to write a portable program that can use ANSI stuff to dress up the screen, but will revert to a dumb line-by-line mode if it's not present. P.S. Looking at CONFIG.SYS for ANSI.SYS is not reliable.
16012_3045@uwovax.uwo.ca (Paul Gomme) (04/01/89)
In article <1920@dataio.Data-IO.COM>, bright@Data-IO.COM (Walter Bright) writes: > I'm looking for a reliable and portable way of determining if ANSI.SYS or > an equivalent driver (NANSI.SYS, FANSI.SYS, ANSI.COM, etc) is loaded. > It should also work with versions of MSDOS that have ANSI.SYS built in > (like the Japanese versions). > My purpose is to write a portable program that can use ANSI stuff to dress > up the screen, but will revert to a dumb line-by-line mode if it's not > present. Get the current cursor position (using ANSI control sequences). Then move the cursor (using ANSI control sequences), and get the cursor position. If the cursor isn't where you put it, ANSI.SYS isn't installed. Only problem with this technique is that if ANSI.SYS isn't installed, the user will see a bunch of garbage. ------------------------------------------------------------------------- Paul Gomme Bitnet: gomme@uwovax.bitnet ARPA: gomme@uwo.ca
cs3b3aj@maccs.McMaster.CA (Stephen M. Dunn) (04/02/89)
I know of a couple of methods. If you know where the screen memory is, you can send a sequence of characters (including some cursor placement strings) which print a recognizable pattern somewhere on the screen, and then look through memory to see if it's where it should be. If so, you know that ANSI is installed. If you know you're working on a machine with an IBM-compatible BIOS, you can do something similar even if you don't know where screen memory is. Repeat the following a few times: use an ANSI escape sequence to move the cursor somewhere, then do a BIOS call (int 10h, function 3) to read the cursor position and see if it's the same. If the cursor ends up where you expect it, you've got ANSI. Alternatively, you could print a string including some escape sequences and then use int 10h function 8 to read what's in screen memory and see if it's what you expect. Hope this helps. Regards -- ====================================================================== ! Stephen M. Dunn, cs3b3aj@maccs.McMaster.CA ! DISCLAIMER: ! ! I always wanted to be a lumberjack! - M.P. ! I'm only an undergrad ! ======================================================================
todd@stiatl.UUCP (Todd Merriman) (04/02/89)
In article <1920@dataio.Data-IO.COM> bright@Data-IO.COM (Walter Bright) writes: >I'm looking for a reliable and portable way of determining if ANSI.SYS or >an equivalent driver (NANSI.SYS, FANSI.SYS, ANSI.COM, etc) is loaded. This can be achieved by transmitting the "cursor position report" escape sequence and waiting to see if anything comes back as in the following: #ifdef DOCUMENTATION /***************************************************************************** .MODULE isansi .LIBRARY clib .TYPE function .APPLICATION screen .SYSTEM msdos .SYSTEM vms .AUTHOR Todd Merriman .LANGUAGE C .DESCRIPTION Check for presence of ANSI terminal .ARGUMENTS boolean isansi() .NARRATIVE Isansi sends the report cursor escape sequence to the console. If nothing is transmitted back, the function returns 0. .RETURNS TRUE if an ANSI terminal is attached, FALSE otherwise. .ENDOC END DOCUMENTATION *****************************************************************************/ #endif /* DOCUMENTATION */ #include <stdio.h> #include "csub.h" /**************************************************************************** Isansi *****************************************************************************/ boolean isansi() { conflush(); /* flush type-ahead */ cputs("\x1B[6n"); /* report cursor position command */ delay(50); /* delay 50 milliseconds */ if (!kbhit()) /* key-pressed? */ { conflush(); return 0; /* no cursor position came back */ } conflush(); return 1; } #ifdef TESTING /* test program */ /***************************************************************************** Main entry *****************************************************************************/ main (argc,argv) int argc; char *argv[]; { puts("ANSI terminal attached?"); puts(isansi()?("YES"):("NO")); puts("> End <"); exit(EXITNORMAL); } /* end of main */ #endif /* TESTING */ /***************************************************************************** End *****************************************************************************/ ...!gatech!stiatl!todd Todd Merriman * 404-377-TOFU * Atlanta, GA Note: I have no idea what my employer's views on the subject are.