home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume34 / vms_rtl_kbd / part02 / demo_kbd$routines.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-19  |  4.8 KB  |  175 lines

  1. /*
  2. ------------------ Distribution and Copyright -----------------
  3. --
  4. -- This software is copyright by the CENA/DGAC/FRANCE
  5. -- All rights reserved.
  6. --
  7. -- No part of the material protected by this copyright notice
  8. -- may be reproduced or utilized for commercial use in any form
  9. -- without written permission of the copyright owner.
  10. --
  11. -- It may be reproduced or utilized for R&D use in Non Profit
  12. -- Organization
  13. --
  14. ---------------------------------------------------------------
  15.  
  16.  
  17. ------------------ Disclaimer ---------------------------------
  18. --
  19. -- This software and its documentation are provided "AS IS" and
  20. -- without any expressed or implied warranties whatsoever.
  21. -- No warranties as to performance, merchantability, or fitness
  22. -- for a particular purpose exist.
  23. --
  24. -- Because of the diversity of conditions and hardware under
  25. -- which this software may be used, no warranty of fitness for
  26. -- a particular purpose is offered.  The user is advised to
  27. -- test the software thoroughly before relying on it.  The user
  28. -- must assume the entire risk and liability of using this
  29. -- software.
  30. --
  31. -- In no event shall any person or organization of people be
  32. -- held responsible for any direct, indirect, consequential
  33. -- or inconsequential damages or lost profits.
  34. --                                                           
  35. -------------------END-PROLOGUE--------------------------------
  36. */
  37.  
  38.  
  39.  
  40.  
  41. /*****************************************************************************
  42.  *****************************************************************************
  43.  **                                        **
  44.  **               D E M O   D E S   R O U T I N E S   K B D $               **
  45.  **                                        **
  46.  ******* Copyright (C) 1992 Centre d'Etudes de la Navigation Aerienne ********
  47.  *****************************************************************************/
  48.  
  49.  
  50.  
  51.  
  52. /*
  53.  * Titre:       DEMO DES ROUTINES KBD$
  54.  *
  55.  * Sujet:       Single keypress under VMS.
  56.  *
  57.  * Version:       1.0-00
  58.  *
  59.  * Description:       Programme de demonstration des routines kbd$.
  60.  *
  61.  *               Ce programme de demonstration met en oeuvre la fonction
  62.  *           kbd$read_keystroke permettant d'attendre une action au
  63.  *           clavier et renvoyant la sequence ANSI correspondant a la
  64.  *           touche actionnee.
  65.  *
  66.  *               Lorsque le tampon est plein, l'utilisateur est prevenu
  67.  *                 par un beep sonore emit par le sous-programme d'IT.
  68.  *
  69.  *               Afin de pouvoir recuperer les codes emis par CTRL/C,
  70.  *                 CTRL/O, CTRL/Q, CTRL/S, CTRL/T, CTRL/X, CTRL/Y et F6, il est
  71.  *                 necessaire d'entrer la commande DCL "SET TERMINAL/PASTHRU
  72.  *                 /NOTTSYNC".
  73.  *
  74.  *                     Pour utiliser kbd$read_keystroke, vous devez appeler au
  75.  *           prealable la fonction kbd$open_keyboard et terminer par
  76.  *           kbd$close_keyboard.
  77.  *                 La routine kbd$open_keyboard permet, entre autres, de ne
  78.  *           creer la zone tampon que si l'on desire reellement utiliser
  79.  *                 kbd$read_keystroke.
  80.  *
  81.  * Langage:       C ANSI
  82.  *
  83.  * Fichier:       DEMO_KBD$ROUTINES.C
  84.  *
  85.  * Environnement:  Machine cible:          VAX
  86.  *                 Systeme d'exploitation: VAX/VMS Version 5.4-3
  87.  *                 Compilateur:            VAX C Version 3.2-044
  88.  *
  89.  * Auteur:       Martin VICENTE (DGAC/CENA/SID)
  90.  *
  91.  *           E-mail: vicente@cenaath.cena.dgac.fr
  92.  *
  93.  *           Mail:   C.E.N.A.
  94.  *               Div. Support Informatique & Developpement
  95.  *               Orly Sud 205
  96.  *               94 542 ORLY AEROGARE CEDEX, FRANCE
  97.  *
  98.  * Creation:       23/05/92
  99.  *
  100.  * Modification:   26/05/92
  101.  *
  102.  */
  103.  
  104.  
  105.  
  106.  
  107. #include <stdio.h>
  108. #include <lib$routines.h>
  109. #include "kbd$routines.h"
  110.  
  111.  
  112. const float  second = 1.0;
  113.  
  114. static void  perform();
  115.  
  116.  
  117. main() 
  118. {
  119.     char                 yes;
  120.     int                  i;
  121.     kbd$t_ansi_sequence  key;
  122.  
  123.  
  124.     perform(kbd$open_keyboard());
  125.  
  126.     (void) printf("Press a key.\n");
  127.  
  128.     do {
  129.     (void) kbd$key_pressed(&yes);
  130.     } while (!yes);
  131.  
  132.     (void) printf("Five loop...\n");
  133.  
  134.     for (i = 0; i < 5; i++) {
  135.         (void) printf("Programme principal (loop): %d\n", i);
  136.         (void) lib$wait(&second);
  137.     }
  138.  
  139.     (void) printf("Five readkey...\n");
  140.  
  141.     for (i = 0; i < 5; i++) {
  142.         (void) printf("Programme principal (SMG code): ");
  143.         perform(kbd$read_keystroke(&key));
  144.         (void) printf("%d\n", kbd$cvt_ansi_smg(&key));
  145.     }
  146.  
  147.     (void) printf("Five loop...\n");
  148.  
  149.     for (i = 0; i < 5; i++) {
  150.         (void) printf("Programme principal (loop): %d\n", i);
  151.         (void) lib$wait(&second);
  152.     }
  153.  
  154.     (void) printf("Flush keyboard.\n");
  155.  
  156.     perform(kbd$flush_keyboard());
  157.  
  158.     (void) printf("Five loop...\n");
  159.  
  160.     for (i = 0; i < 5; i++) {
  161.         (void) printf("Programme principal (loop): %d\n", i);
  162.         (void) lib$wait(&second);
  163.     }
  164.  
  165.     (void) printf("End\n");
  166.  
  167.     perform(kbd$close_keyboard());
  168. }
  169.  
  170.  
  171. static void perform(unsigned cond_value)
  172. {
  173.     if (!(cond_value & 1)) (void) lib$stop(cond_value);
  174. }
  175.