From:	SMTP%"worlton@ANPNS6.PNS.ANL.GOV" 28-MAR-1994 08:34:58.39
To:	EVERHART
CC:	
Subj:	Re: getting screen width and length in VAX C

X-Newsgroups: comp.os.vms
From: worlton@ANPNS6.PNS.ANL.GOV
Subject: Re: getting screen width and length in VAX C
Message-Id: <Cn8tLH.Fx8@mcs.anl.gov>
Sender: usenet@mcs.anl.gov
Reply-To: worlton@ANPNS6.PNS.ANL.GOV
Organization: IPNS Division, Argonne National Laboratory
Date: Fri, 25 Mar 1994 23:08:04 GMT
Lines: 104
To: Info-VAX@CRVAX.SRI.COM
X-Gateway-Source-Info: USENET

In article <2mv1mi$dpe@thor.cs.umass.edu>, vasant@mildura.cs.umass.edu (Vasanthakumar S. R.) writes:
>Hi 
>        I am porting C code from UNIX environment to VMS (VAX C compiler). I 
>am new to VMS and VAX C.I am having difficulty to get screen width and screen length in VMS. 
>
>        In UNIX we use "ioctl" function to update "winsize" structure, which
>has screen length and width. Could any of the VAX C users let me know the equivalent in VAX C. 
>
>        I appreciate your help.
>
>Thanks
>
>vasant
Ten years ago I wrote a Fortran program to do this.  If you don't want to use
Fortran, maybe it will still give you an idea what to do.  This subroutine will 
get the page length (number of rows), and the screen width (number of columns).
Subroutine gets the information and sterm sets it.  They also get and set 
the form feed characteristic.  I used that in printing to a printer on the 
printer port, but that part could be stripped out.  Since the code isn't too
long I will post it.

Tom Worlton
----------------------------------------
	subroutine gterm(page,screen,form)
c
c	Subroutine to determine and change terminal characteristics
c
C
C	PROGRAMMER:	T. G. Worlton
C			Argonne National Lab
C			Version 1.0	3/21/84
	implicit	integer*4 (a-z)
	character	local*2,chn_buf*64
	byte		chn_buf_byte(64),rest_byte(30),ddi_byte(4),
	1		class,type,page_len
	integer*2	buf_size,unit_no,name_off,
	1		vol_pro,err_cnt,label_off
	integer*2	loc_chan,iosb(4)
	equivalence	(chn_buf,chn_buf_byte),
	1		(chn_buf_byte,dev_char)
	equivalence	(dev_dep_info,ddi_byte),
	1		(ddi_byte(4),page_len)
	common /pribuf/	dev_char,
	1		class,type,buf_size,
	1		dev_dep_info,
	1		unit_no,name_off,
	1		pid,
	1		uic,
	1		vol_pro,err_cnt,
	1		op_cnt,
	1		label_off,rest_byte
	external	io$_setmode,
	1		tt$m _wrap,tt$m_ttsync,tt$m_mechtab,
	1		tt$m_mechform
	data		local/'TT'/
	data		ifg/0/
c
c	Assign channel number
	if(ifg .ne. 1) then
		status=sys$assign(local,loc_chan,,)
		if (.not.status) call lib$stop(%val(status))
		ifg = 1
	end if
c
c	get terminal characteristics
	status=sys$getchn(%val(loc_chan),,chn_buf,,)
	if (.not.status) call lib$stop(%val(status))
c
	page = page_len
	screen = buf_size
	iform = dev_dep_info .and. %loc(tt$m_mechform)
	if(iform .eq. 0) then
		form = .false.
	else
		form = .true.
	end if
	return

	entry sterm(page,screen,form)
	if(ifg .ne. 1) then
		status=sys$assign(local,loc_chan,,)
		if (.not.status) call lib$stop(%val(status))
		status=sys$getchn(%val(loc_chan),,chn_buf,,)
		if (.not.status) call lib$stop(%val(status))
		ifg = 1
	end if
	page_len = page
	buf_size = screen
	if(form) then
		dev_dep_info = dev_dep_info
	1	.or.  %loc(tt$m_mechform)
	else
		dev_dep_info = dev_dep_info
	1	.xor. %loc(tt$m_mechform)
	end if
	status = sys$qiow(,%val(loc_chan),io$_setmode,iosb,,,
	1		class,,,,,)
	return
	end
--------------------------------------------------------
***************************************************************************
Tom Worlton << tgworlton@anl.gov >>	   road kill on the
Argonne National Laboratory		information superhighway
***************************************************************************

