home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / ms95 / disk22 / dir04 / f014410.re_ / f014410.re
Text File  |  1996-04-02  |  7KB  |  203 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/output.mcv  $
  18. |   $Workfile:   output.mc  $
  19. |   $Revision:   5.2  $
  20. |       $Date:   20 Jun 1995 08:49:48  $
  21. |                                    |
  22. +----------------------------------------------------------------------*/
  23. /*----------------------------------------------------------------------+
  24. |                                    |
  25. |   output.mc - examples for the mdlOutput_ 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    <stdarg.h>
  40. #include    <tcb.h>
  41.  
  42. /*----------------------------------------------------------------------+
  43. |                                    |
  44. |   Function declarations                        |
  45. |                                    |
  46. +----------------------------------------------------------------------*/
  47.  
  48. void    messagePrintf (char *, ...) ;
  49.     
  50. /*----------------------------------------------------------------------+
  51. |                                    |
  52. | name        outputU                            |
  53. |                                    |
  54. | author    BSI                     9/90        |
  55. |                                    |
  56. |    This function illustrates use of the output functions that    |
  57. |    display messages regardless of whether messages are inhibited.  |
  58. |                                    |
  59. +----------------------------------------------------------------------*/
  60. cmdName void outputU
  61. (
  62. )
  63.     {
  64.     mdlOutput_errorU ("UNINHIBITED ERROR");
  65.     mdlOutput_promptU ("UNINHIBITED PROMPT");
  66.     mdlOutput_messageU ("UNINHIBITED MESSAGE");
  67.     mdlOutput_statusU ("UNINHIBITED STATUS");
  68.     mdlOutput_commandU ("UNINHIBITED COMMAND");
  69.     mdlOutput_keyinU ("UNINHIBITED KEYIN");
  70.     }
  71.  
  72. /*----------------------------------------------------------------------+
  73. |                                    |
  74. | name        output                             |
  75. |                                    |
  76. | author    BSI                     9/90        |
  77. |                                    |
  78. |    This function illustrates use of the output functions that    |
  79. |    are affected by whether the messages are inhibited.        |
  80. |                                    |
  81. +----------------------------------------------------------------------*/
  82. cmdName void output 
  83. (
  84. )
  85.     {
  86.     mdlOutput_error ("ERROR");
  87.     mdlOutput_prompt ("PROMPT");
  88.     mdlOutput_message ("MESSAGE");
  89.     mdlOutput_status ("STATUS");
  90.     mdlOutput_command ("COMMAND");
  91.     mdlOutput_keyin ("KEYIN");
  92.     }
  93.  
  94. /*----------------------------------------------------------------------+
  95. |                                    |
  96. | name        messages                        |
  97. |                                    |
  98. | author    BSI                     9/90        |
  99. |                                    |
  100. |    This function toggles the messages-inhibit bit in the TCB.    |
  101. |                                    |
  102. +----------------------------------------------------------------------*/
  103. cmdName messages
  104. (
  105. void
  106. )
  107.     {
  108.     tcb->control.inh_msg ^= 1;
  109.     if (tcb->control.inh_msg)
  110.     mdlOutput_statusU ("Status messages are inhibited.");
  111.     else
  112.     mdlOutput_statusU ("Status messages are not inhibited.");
  113.     }
  114.     
  115. /*----------------------------------------------------------------------+
  116. |                                    |
  117. | name        errors                            |
  118. |                                    |
  119. | author    BSI                     9/90        |
  120. |                                    |
  121. |    This function toggles the error-inhibit bit in the TCB.        |
  122. |                                    |
  123. +----------------------------------------------------------------------*/
  124. cmdName errors
  125. (
  126. void
  127. )
  128.     {
  129.     tcb->control.inh_err ^= 1;
  130.     if (tcb->control.inh_err)
  131.     mdlOutput_statusU ("Error messages are inhibited.");
  132.     else
  133.     mdlOutput_statusU ("Error messages are not inhibited.");
  134.     }
  135.  
  136. /*----------------------------------------------------------------------+
  137. |                                    |
  138. | name        testPrintf                          |
  139. |                                    |
  140. | author    BSI                     9/90        |
  141. |                                    |
  142. |    This function illustrates mdlOutput_printf.  mdlOutput_printf   |
  143. |    is like printf, except that it also takes a paramter that       |
  144. |    specifies a field in the MicroStation Command Window.       |
  145. |                                    |
  146. +----------------------------------------------------------------------*/
  147. cmdName testPrintf
  148. (
  149. char    *echoP
  150. )
  151.     {
  152.     mdlOutput_printf (MSG_STATUS, "Testing testPrintf");
  153.     mdlOutput_printf (MSG_MESSAGE, "ECHOED: \"%s\"", echoP);
  154.     }
  155.  
  156. /*----------------------------------------------------------------------+
  157. |                                    |
  158. | name        callMessage                        |
  159. |                                    |
  160. | author    BSI                     9/90        |
  161. |                                    |
  162. |    This command just calls messagePrintf.              |
  163. |                                    |
  164. +----------------------------------------------------------------------*/
  165. cmdName callMessage
  166. (
  167. void
  168. )
  169.     {
  170.     messagePrintf ("INT %d DOUBLE %g STRING %s", 100, 200., "Hello");
  171.     }
  172.     
  173. /*----------------------------------------------------------------------+
  174. |                                    |
  175. | name        messagePrintf                       |
  176. |                                    |
  177. | author    BSI                     9/90        |
  178. |                                    |
  179. |    This function illustrates the use of mdlOutput_vprintf.        |
  180. |    mdlOutput_vprintf is like vprintf, except that it also takes    |
  181. |    a paramter that specifies a field in the MicroStation Command   |
  182. |    Window.                                |
  183. |                                    |
  184. |    messagePrintf is essentially a printf that always displays      |
  185. |    messages to the the message field of the Command Window.    |
  186. |                                    |
  187. +----------------------------------------------------------------------*/
  188. Private void messagePrintf
  189. (
  190. char    *formatP,
  191. ...
  192. )
  193.     {
  194.     va_list    ap;
  195.  
  196.     /* Make ap point to the first named argument. */
  197.     va_start (ap, formatP);
  198.     
  199.     mdlOutput_vprintf (MSG_MESSAGE, formatP, ap);
  200.     
  201.     va_end (ap);
  202.     }
  203.