From:	CSBVAX::MRGATE!info-vax-request@kl.sri.com@SMTP 23-MAR-1988 09:32
To:	ARISIA::EVERHART
Subj:	Re: Need single character input on VAX Pascal...


Received: from ucbvax.Berkeley.EDU by KL.SRI.COM with TCP; Sun 20 Mar 88 15:22:57-PST
Received: by ucbvax.Berkeley.EDU (5.58/1.26)
	id AA15069; Sun, 20 Mar 88 12:17:05 PST
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: 20 Mar 88 03:22:05 GMT
From: bsu-cs!mithomas@iuvax.cs.indiana.edu  (Michael Thomas Niehaus)
Organization: CS Dept, Ball St U, Muncie, Indiana
Subject: Re: Need single character input on VAX Pascal...
Message-Id: <2418@bsu-cs.UUCP>
References: <7787@cisunx.UUCP>, <2394@bsu-cs.UUCP>
Sender: info-vax-request@kl.sri.com
To: info-vax@kl.sri.com

In article <2394@bsu-cs.UUCP>, cfchiesa@bsu-cs.UUCP (Christopher Chiesa) writes:
> In article <7787@cisunx.UUCP>, bumpy@cisunx.UUCP (Michael Stopper) writes:
> 
> > Does anyone out there have a routine for VAX Pascal to read a single char
> > from the terminal in VAX Pascal without having to press the ever-present
> > RETURN key??  I have a prog which prompts for a single character response

> Yes.  Below you will find a MACRO Assembly routine which will do what you re-
> quest.  It may be called from any Vax/VMS programming language, including Pas-
> cal, without strenuous or obscure data-type-matching effort. 

Well, I wouldn't call using a BASIC subroutine and the corresponding data-
matching an obscure effort.  It would definitely be more understandable and
straight-forward to any programmer.  It's almost like you are bragging about
knowing MACRO.  (That would be like be bragging about knowing IBM S/370
Assembler.  Blah!)

> To obtain a character:                 To obtain an integer:
> --------------------------------       _____________________________
> [EXTERNAL]                              [EXTERNAL]
> PROCEDURE In_Char (VAR c:char);         PROCEDURE In_Char (VAR n: integer); 
>   EXTERN;                                 EXTERN;
> 
> To use it, of course, just invoke it by name:
> 
>     In_Char(x);    (* 'x' gets the next character from the terminal. *)
> 
> -- Chris Chiesa
[LONG MACRO program deleted]

Try using this BASIC routine to input a single character

Sub In_char(string a)
  a=inkey$(0%,wait)    ! 0% is the keyboard channel.  WAIT indefinitely.
End Sub

That's ALL of it.  Compile this with BASIC, then link it with your main
program using the same 'char' PROCEDURE definition listed above.
If you want better, more complex, define a TYPE as VARYING[255] OF CHAR.
Substitute 'VAR c:Var_type' for the procedure parameter list, and also
declare a variable for the receiving end.  The only reason to go through all
of this trouble is the fact that the BASIC routine will return a 3 or 4
character string that you can use any time someone presses a function key.
For example, if you press the GOLD key on a VT240, the BASIC routine will
return 'PF1'.  This goes for all of the other function/keypad keys also.

Hope this is helpful.

Michael Niehaus
Also from Ball State
UUCP: ..!{uunet,pur-ee,iuvax}!bsu-cs!mithomas
AppleLink: U0698
