home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!ucbvax!NKUVAX.BITNET!FINLEY
- From: FINLEY@NKUVAX.BITNET (Kevin Finley)
- Newsgroups: comp.os.vms
- Subject: Re: Easy Way to trap for Control-Z In VAX C?
- Message-ID: <01GQZFW3KCAA8WW9G8@NKUVAX.BITNET>
- Date: 10 Nov 92 15:07:20 GMT
- Sender: daemon@ucbvax.BERKELEY.EDU
- Distribution: world
- Organization: The Internet
- Lines: 65
-
- >Netters,
- > Is there any good way to trap for a Control-Z keystroke in Vax C? I have
- >looked in manual after manual looking for some hint of what to do. A friend of
- >mine has told me it was 26 in the ASCII character set. (or that is how he uses
- >it in Pascal) However any attempts to use something like if (input == 26) where
- >the input is of type char.
- > Any hints, and better yet samples of C source would be apprecated. Also,
- >since we're on the subject, are similar ways to trap Control-Y and T possible?
-
-
- > Joshua
-
- >(****************************************************************************)
- >(* ***** * * * * | Name : Joshua J. Hart Ack _,_/| *)
- >(* * * * * * | Bitnet : STUHART@EKU; hart%eagle@eku \ \o.O; *)
- >(* **** * * * * | Internet : AN984@Cleveland.Freenet.Edu =(___)=*)
- >(* * *** * * | School : Eastern Kentucky University U *)
- >(* * * * * * | Major : Forensic Chemistry / Computer Science *)
- >(* ***** * * ** | Disclaimer: Opinions are Mine, No one else wants Em*)
- >(****************************************************************************)
- >%SYSTEM-W-TMNYFNGRS, too many fingers on keyboard
-
- Yes, I am sorry I took so long to reply. I've been very busy. Here is a
- simple program to use. This program takes input received, and echos it out if
- it is printable or echos its ascii code if not. This program doesn't trap
- control-y/c or control-t because the Queued Input Output (QIO) services don't,
- sorry. I ran it and it traps control-z as 26 and escape as it should at 27.
-
- I hope this helps. Please send any replies to me personally. I unsubscribed
- to info-vax because it requires too much of my time to keep it from blowing my
- disk quota.
-
- #include <ctype.h>
- #include <limits.h>
- #include <iodef.h>
- #include <psldef.h>
- #include <ssdef.h>
- #include <stdio.h>
- #include <descrip.h>
-
- #define TMPMBX 0
- #define PROT_MASK 0
-
-
- main()
- {
- char this;
- unsigned short chan;
- int stat;
-
- $DESCRIPTOR ( dev_descriptor, "SYS$OUTPUT:" );
-
- sys$assign ( &dev_descriptor, &chan, PSL$C_USER, NULL );
- loop:
- stat = sys$qiow ( SS$_NORMAL, chan, IO$_READLBLK, NULL, NULL, NULL,
- &this, 1, NULL, NULL, NULL, NULL );
- if ( isprint ( this ) )
- printf ( "char: %c\n", this );
- else
- printf ( "code: %d\n", (int) this );
- if ( this != 'z' )
- goto loop;
- }
-
-
-