[mod.computers.masscomp] detecting a graphics terminal in a program

sob@soma.bcm.tmc.edu.bcm.tmc.edu (Stan Barber) (10/17/86)

Have you ever wondered how a program can detect if the user is at
a graphics terminal? It's really easy....

Here is a sample of how to do it with a fortran callable function written
in C:

/* is this a graphics device that I am on? */
/* $Header: isgraphics.c,v 1.1 86/10/16 16:19:02 lab Exp $
 * By Stan Barber
 * $Log:	isgraphics.c,v $
 * Revision 1.1  86/10/16  16:19:02  lab
 * Initial revision
 * 
 *
 */
#include <windefs.h>
#include <stdio.h>
isgraphics_()
{
	WINDOWDATA WD;
	int i;
	i=ioctl(fileno(stdout),WIOCGETD,&WD);
	if (i == 0) return(1);
	return(0);
}


This will return a 1 if you are on a graphics terminal and 0 if not.
I would like to make this a logical, but the documentation is
not specific on how to do this...Maybe a Westford person can tell us...
Here is a sample program to use to test this:

	program testidgr
	integer j
	
	j = isgraphics(0)
	print *,j
	end

The compiler command to use is:
f77 -o testidgr testidgr.f isgraphics.c

If anyone has any more shorts to contribute, please feel free.