### Example (_parmdwords -- Get Number of dwords in Parameter List)

This example shows two versions of an API that prints out messages. The second version uses __parmdwords to determine whether the call was intended for the original or the updated version.

    #include <stdlib.h>
    #include <stdio.h>

    int _System ErrorHandler(int MessgageNum,int Severity); /* Extended version of API */

    /* Old version API prototype --  int ErrorHandler(int MessageNum);                 */

    #define  MESSAGE1      1
    #define  MESSAGE2      2
    #define  INFORMATIONAL 3
    #define  WARNING       2
    #define  ERROR         1
    #define  FATAL         0

    int _System ErrorHandler(int MessageNum,int Severity)
    {
       int rc = 0;

       switch ((int)__parmdwords()) {
          case 2 :             /* Extended version with Severity parameter             */
             switch (Severity) {
                case  FATAL :
                   printf("Fatal Error:");
                   break;
                case  ERROR :
                   printf("Error:");
                   break;
                case  WARNING :
                   printf("Warning:");
                   break;
                case  INFORMATIONAL :
                   printf("Informational:");
                   break;
                default  :
                   rc = EXIT_FAILURE;
                   printf("Bad Severity Number");
             }

           /* intentional fall through                                                 */

          case 1 :        /* Old version of API without Severity parameter             */
             switch (MessageNum) {
                case  MESSAGE1 :
                   printf("Some immensely profound message\n");
                   break;
                case  MESSAGE2 :
                   printf("Some other immensely profound message\n");
                   break;
                default  :
                   printf
                      ("Very trivial message, why not try MESSAGE1 or MESSAGE2?\n");
                   rc = EXIT_FAILURE;
             }
       }
       return  rc;
    }

    int main(void)
    {
       return ErrorHandler(MESSAGE1, FATAL);

       /*****************************************************************************
          The output should be:

          Fatal Error: Some immensely profound message
       *****************************************************************************/
    }