From:	CRDGW2::CRDGW2::MRGATE::"SMTP::CRVAX.SRI.COM::RELAY-INFO-VAX" 17-MAR-1991 19:58:21.19
To:	ARISIA::EVERHART
CC:	
Subj:	Re: vax pascal

From:	RELAY-INFO-VAX@CRVAX.SRI.COM@SMTP@CRDGW2
To:	Everhart@Arisia@MRGATE

Received:  by crdgw1.ge.com (5.57/GE 1.91)
	 id AA09991; Sun, 17 Mar 91 19:50:21 EST
Received: From UCBVAX.BERKELEY.EDU by CRVAX.SRI.COM with TCP; Sun, 17 MAR 91 15:49:30 PST
Received: by ucbvax.Berkeley.EDU (5.63/1.42)
	id AA10202; Sun, 17 Mar 91 15:42:13 -0800
Received: from USENET by ucbvax.Berkeley.EDU with netnews
	for info-vax@kl.sri.com (info-vax@kl.sri.com)
	(contact usenet@ucbvax.Berkeley.EDU if you have questions)
Date: 17 Mar 91 23:36:26 GMT
From: zaphod.mps.ohio-state.edu!usc!jarthur!dsolomon@tut.cis.ohio-state.edu  (Daniel Solomon)
Organization: Harvey Mudd College, Claremont, CA 91711
Subject: Re: vax pascal
Message-Id: <11272@jarthur.Claremont.EDU>
References: <1991Mar17.200353.10532@bronze.ucs.indiana.edu>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <1991Mar17.200353.10532@bronze.ucs.indiana.edu> sl243017@silver.ucs.indiana.edu (SSowder Utils) writes:
>Hello I am a Pc users that has been transplanted.  I am used to my
>                While NOT keypress do;
>lines in turbo pascal.  Can someone mail me the equivilant in vax pascal?
>Thanks I just wish to have the computer wait until a key is pressed.
>-Sid

The program below is a slight modification of something I already had.  You
just use the command KEYPRESS to wait for a key, and it has the added
benefit of being able to return the key that is pressed.  I hope that this
works for you.

		- Dan Solomon

----------------------------------------------------------------------------
dsolomon@hmcvax.claremont.edu   |  "No amount of planning will ever replace
dsolomon@jarthur.claremont.edu  |     dumb luck"  
----------------------------------------------------------------------------
"At that moment, an event--or is 'event' the word for it?--takes place which
cannot be described, and hence no attempt will be made to describe it."

{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		HITKEY - Hit any key to continue

		Written by:	Daniel Solomon
				Harvey Mudd College
				3/17/91

This is a function that will simulate the sorely needed 'Hit any key to
continue' type of function that PASCAL doesn't have.  It is currently set
up to not use a prompt, but by changing the appropriate commented out parts,
a prompt can be used.  The function returns back the character pressed.  Any
typeahead is eliminated.  Also, with function keys and keypad keys, an escape
is returned, and the other two characters are stored.  They aren't returned
back, but the function could easily be modified to include them.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}

[inherit('sys$library:starlet')]

program hitkey (input,output);

const	keyprompt = 'Hit any key to continue';

type	uword = [WORD] 0..65535;
	string = varying [80] of char;

var	tt_channel : uword;
	pressed : char;

function KEYPRESS : char;

   var	flags : uword;
	key : char;
	overflow : varying [2] of char;
	status : unsigned;
        prompt : string;

   begin
     prompt := keyprompt;	{Gets the prompt for promted reads}
     flags := IO$_READVBLK +	{For prompt, use instead: IO$_READPROMPT +}
              IO$M_NOFILTR + IO$M_NOECHO + IO$M_PURGE;
     status := $qiow(,tt_channel,flags,,,,key,1,0,0
                     {,iaddress(prompt.BODY),prompt.LENGTH});
	{Now we need to get rid of any extra characters.  Most likely this
	 will be due to escape combinations.  We can take care of it with a
	 two character buffer and a zero second timeout.  This will get any
	 characters in the typeahead buffer.  Note:  I've found that if you
	 hit keys really fast, they might register before the timeout.}
     status := $qiow(,tt_channel,
                     IO$_READVBLK + IO$M_NOFILTR + IO$M_NOECHO + IO$M_TIMED,,,,
                     overflow,2,0,0);
	{Just a precaution.  If anything funky happens that I haven't taken
	 into account, it will probably give an error.  In that case, I just
	 have it return a carriage return.}
     if odd(status)
       then KEYPRESS := key
       else KEYPRESS := chr(13);
   end;


begin
   $assign('tt:',tt_channel);	{An output channel to tt: for the $qio call}

     pressed := KEYPRESS;
     writeln(ord(pressed));

   $dassgn(tt_channel);
end.

