home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / ms95 / disk22 / dir04 / f014480.re_ / f014480.re
Text File  |  1996-04-02  |  5KB  |  147 lines

  1. /*----------------------------------------------------------------------+
  2. |                                    |
  3. |  Copyright (1995) Bentley Systems, Inc., All rights reserved.        |
  4. |                                    |
  5. |  "MicroStation" is a registered trademark and "MDL" and "MicroCSL"    |
  6. |  are trademarks of Bentley Systems, Inc.                    |
  7. |                                    |
  8. |  Limited permission is hereby granted to reproduce and modify this    |
  9. |  copyrighted material provided that the resulting code is used only     |
  10. |  in conjunction with Bentley Systems products under the terms of the    |
  11. |  license agreement provided therein, and that this notice is retained    |
  12. |  in its entirety in any such reproduction or modification.        |
  13. |                                    |
  14. +----------------------------------------------------------------------*/
  15. /*----------------------------------------------------------------------+
  16. |                                    |
  17. |    $Logfile:   J:/mdl/examples/doc/tutorial.mcv  $
  18. |   $Workfile:   tutorial.mc  $
  19. |   $Revision:   5.2  $
  20. |       $Date:   20 Jun 1995 08:49:44  $
  21. |                                    |
  22. +----------------------------------------------------------------------*/
  23. /*----------------------------------------------------------------------+
  24. |                                    |
  25. |   tutorial.mc - examples for the mdltutorial_ functions.        |
  26. |                                    |
  27. |   This file is intended as an adjunct to the MDL manual to        |
  28. |   illustrate MDL built-in function calling conventions and parameter    |
  29. |   values. While it can be compiled, it does NOT, on its own,        |
  30. |   constitute a workable MDL example.                    |
  31. |                                    |
  32. +----------------------------------------------------------------------*/
  33. /*----------------------------------------------------------------------+
  34. |                                    |
  35. |   Include Files                               |
  36. |                                    |
  37. +----------------------------------------------------------------------*/
  38. #include    <mdl.h>        /* system include files */
  39. #include    <userfnc.h>
  40. #include    <msinputq.h>
  41.  
  42. /*----------------------------------------------------------------------+
  43. |                                    |
  44. |   Function declarations                        |
  45. |                                    |
  46. +----------------------------------------------------------------------*/
  47.  
  48. void        receiveMessage (), monitorQueue ();
  49.  
  50. /*----------------------------------------------------------------------+
  51. |                                    |
  52. | name        main                            |
  53. |                                    |
  54. | author    BSI                     9/90        |
  55. |                                    |
  56. +----------------------------------------------------------------------*/
  57. main ()
  58.     {
  59.     if (mdlTutorial_load ("sample") != SUCCESS)
  60.     /* mdlTutorial_load displays an error message */
  61.     exit (1);
  62.  
  63.     /*  Install some MDL input user functions. */
  64.     mdlInput_setMonitorFunction (MONITOR_ALL, monitorQueue);
  65.     mdlInput_setFunction (INPUT_MESSAGE_RECEIVED, receiveMessage);
  66.     }
  67.  
  68. /*----------------------------------------------------------------------+
  69. |                                    |
  70. | name        monitorQueue                                  |
  71. |                                    |
  72. | author    BSI                     9/90        |
  73. |                                    |
  74. |    monitorQueue is an example of a input-monitor user function.    |
  75. |    See userInput_monitor in the MDL documentation for more     |
  76. |    information.                            |
  77. |                                    |
  78. +----------------------------------------------------------------------*/
  79. Private int monitorQueue
  80. (
  81. Inputq_element    *queueElementP
  82. )
  83.     {
  84.     /*  If this is a tutorial keyin, redirect it to this application
  85.         instead of letting MicroStation handle it. */
  86.     if (queueElementP->hdr.cmdtype == TUTKEYIN)
  87.     strcpy (queueElementP->hdr.taskId, mdlSystem_getCurrTaskID ());
  88.  
  89.     return INPUT_ACCEPT;
  90.     }
  91.  
  92. /*----------------------------------------------------------------------+
  93. |                                    |
  94. | name        receiveMessage                                  |
  95. |                                    |
  96. | author    BSI                     9/90        |
  97. |                                    |
  98. |    This is a input-receive user function.  See userInput_receive   |
  99. |    in the MDL manual for more information.             |
  100. |                                    |
  101. |    This function receives the messages that monitorQueue        |
  102. |    redirects to this application.                  |
  103. |                                    |
  104. |    This functions justs echos the tutorial keyin to an output      |
  105. |    field.  It is assumed that fields 1-3 are input fields and      |
  106. |    field 4-6 are output fields.                    |
  107. |                                    |
  108. +----------------------------------------------------------------------*/
  109. Private int receiveMessage
  110. (
  111. Inputq_element    *queueElementP
  112. )
  113.     {
  114.     char    buffer [80];
  115.     
  116.     strcpy (buffer, "OUTPUT ");
  117.     strcat (buffer, queueElementP->u.tutkeyin.keyin);
  118.     mdlTutorial_output (queueElementP->hdr.uc_fno_value+3, buffer, 
  119.                 strlen (buffer));
  120.     }
  121.  
  122. /*----------------------------------------------------------------------+
  123. |                                    |
  124. | name        chooseField                        |
  125. |                                    |
  126. | author    BSI                     9/90        |
  127. |                                    |
  128. +----------------------------------------------------------------------*/
  129. cmdName chooseField
  130. (
  131. char    *fieldP
  132. )
  133.     {
  134.     int    fieldNumber;
  135.     
  136.     if ((sscanf (fieldP, "%d", &fieldNumber) != 1) ||
  137.     (fieldNumber < -2 || fieldNumber > 3))
  138.     {
  139.     mdlOutput_error ("Expected a field number between -1 and 3.");
  140.     return;
  141.     }
  142.  
  143.     /* Select the desited field and draw the box. */
  144.     mdlTutorial_positionInputField (fieldNumber, 1);
  145.     }
  146.     
  147.