home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / devddemo.zip / PRTMSG.C < prev    next >
Text File  |  1991-02-02  |  4KB  |  105 lines

  1. /*****************************************************************************/
  2. /*  prt_msg(msg,val)                                                         */
  3. /*          - Print a selected message, possibly with a parameter value      */
  4. /*                                                                           */
  5. /*****************************************************************************/
  6. /*                                                                           */
  7. /* This function works with the DOSGETMESSAGE and DOSPUTMESSAGE OS calls.    */
  8. /* That is why it only works at INIT time. (INIT time is the only time a DD  */
  9. /* can do any architected screen IO anyway).  There also seems to be a bug   */
  10. /* in the message handler when the caller wants to wait for an ENTER, OS/2   */
  11. /* just keeps on going, it doesn't wait.  That is why the DOSREAD is in      */
  12. /* case 7.                                                                   */
  13. /*                                                                           */
  14. /* The message file name is constructed by PARSPARM which creates it from    */
  15. /* the DD file name.                                                         */
  16. /*                                                                           */
  17. /*   Message   Use of parm           Message                                 */
  18. /*     1        Not Used        Loading commercial                           */
  19. /*     2        Not Used        Press Enter to continue                      */
  20. /*                                                                           */
  21. /*****************************************************************************/
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25. #include <doscalls.h>
  26. #include "demo.h"
  27. #include "version.h"
  28. static char near valstr[6];
  29.        char near msg_file[255];
  30.  
  31.  
  32. void far make_msg_fname( char *line)
  33. {
  34. char *token;
  35. char *found;
  36.  
  37.   /* get the DD file name */
  38.   token = strtok(line," ");
  39.  
  40.   /* Make the message file name from the DD file name */
  41.   strcpy(msg_file,token);             /* Copy the DD fname to msg fname      */
  42.   found = strchr(msg_file,(int)'.');  /* Find the . in the fname             */
  43.   if (found == NULL) {                /* If there is no .                    */
  44.      found = strchr(msg_file,0);      /*    Find the end of the name         */
  45.      found[0] = '.';                  /*    And make it a dot                */
  46.      }
  47.   found[1] = 'M';                     /* Make the chars after the dot MSG    */
  48.   found[2] = 'S';
  49.   found[3] = 'G';
  50.   found[4] = '\0';                    /* and put a terminator                */
  51.  
  52. }
  53.  
  54. unsigned far prt_msg(msg,val1)
  55. unsigned msg;
  56. unsigned val1;
  57. {
  58.    char message[80];
  59.    char num1[10];
  60.    char num2[10];
  61.    char *pointers[2];
  62.    unsigned mlen;
  63.    unsigned i;
  64.  
  65.    switch (msg) {
  66.  
  67.    case 1 : /* The loading commercial */
  68.  
  69.       /* Three lines of intro stuff   */
  70.       for (i = 1; i <= 2; i++) {
  71.          DOSGETMESSAGE(NULL,0,message,80,i,msg_file,&mlen);
  72.          DOSPUTMESSAGE(1,mlen,message);
  73.          }
  74.  
  75.       /* Put the major and minor versions into the array for the  */
  76.       /* message handler to use in the next line                  */
  77.       itoa(VER_MAJ,num1,10);
  78.       pointers[0] = (char *)num1;
  79.       i = 0;
  80.       if (VER_MIN < 10) {
  81.          num2[i++] = '0';
  82.          }
  83.       itoa(VER_MIN,(num2+i),10);
  84.       pointers[1] = (char *)num2;
  85.       DOSGETMESSAGE(pointers,2,message,80,3,msg_file,&mlen);
  86.       DOSPUTMESSAGE(1,mlen,message);
  87.  
  88.       /* And the end stuff         */
  89.       DOSGETMESSAGE(NULL,0,message,80,4,msg_file,&mlen);
  90.       DOSPUTMESSAGE(1,mlen,message);
  91.  
  92.       return(0);
  93.       break;
  94.  
  95.    case 2 : /* Press Enter */
  96.       DOSGETMESSAGE(NULL,0,message,80,5,msg_file,&mlen);
  97.       DOSPUTMESSAGE(1,mlen,message);
  98.       DOSREAD(1,message,80,&mlen);
  99.       return(0);
  100.       break;
  101.  
  102.       }
  103.  
  104. }
  105.