home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 35 / hot35.iso / ficheros / 9TXT / ZE32V270.ZIP / ZMI.ZM_ / ZMI.ZM
Text File  |  1998-05-23  |  6KB  |  140 lines

  1. //------------------------------------------------------------------------
  2. //--      Author: Jussi Jumppanen (xidicone@iname.com)
  3. //--   Home Page: http://ourworld.compuserve.com/homepages/jussi
  4. //--       Usage: ZMI.EXE Zmi.zm
  5. //------------------------------------------------------------------------
  6.  
  7. int TestMacro(void)
  8. {
  9.    string strBuffer;
  10.  
  11.    //
  12.    // This is a simple menu spawn written using the Zeus Macro language
  13.    //
  14.    while (1)
  15.    {
  16.       // Display a menu of option
  17.       cls();
  18.       printf("\n Zeus Macro Test Script             ");
  19.       printf("\n ----------------------             ");
  20.       printf("\n 1) About the Zeus Interpreter      ");
  21.       printf("\n 2) View the source for this macro  ");
  22.       printf("\n 3) Spawn a system command test case");
  23.       printf("\n 4) Loop test case                  ");
  24.       printf("\n 5) String test case                ");
  25.       printf("\n 6) Quit macro\n                    ");
  26.       printf("\n Input the required selection: "     );
  27.  
  28.       get_number(sNumber);
  29.  
  30.       cls();
  31.  
  32.       // Process the item selected
  33.       if (sNumber == 1)
  34.       {
  35.          printf("\n About the Zeus Interpreter                              ");
  36.          printf("\n --------------------------                              ");
  37.          printf("\n This interpret  implements a simple macro  language that");
  38.          printf("\n supports a small  subset of the  C language syntax. This");
  39.          printf("\n test macro  can be run  using the ZMI.EXE intepreter and");
  40.          printf("\n you can  download the source, exe and document files for");
  41.          printf("\n a cutdown version of the macro intepreter from the tools");
  42.          printf("\n section the following home page:\n                      ");
  43.          printf("\n    http://ourworld.compuserve.com/homepages/jussi\n     ");
  44.       }
  45.       else if (sNumber == 2)
  46.       {
  47.          printf("\n View the Source for This Macro                      ");
  48.          printf("\n ------------------------------                      ");
  49.          printf("\n The source of this macro script is contained in the ");
  50.          printf("\n file 'Zmi.zm'.  The  contents of this file will now ");
  51.          printf("\n be displayed.\n                                     ");
  52.          printf("\n Hit any key to start the display.....\n             ");
  53.          getch();
  54.  
  55.          //-- build up the MS-DOS command 
  56.          sprintf(strBuffer, "type %s | more", argv[1]);
  57.          printf("\n  About to run the '%s' command.\n", strBuffer);
  58.          spawn(strBuffer);
  59.       }
  60.       else if (sNumber == 3)
  61.       {
  62.          printf("\n Spawn System Command Test Case                          ");
  63.          printf("\n ------------------------------                          ");
  64.          printf("\n Input  the command to run. If you are  running an MS-DOS");
  65.          printf("\n machine  enter  any  DOS  command (ie dir *.*)  or enter");
  66.          printf("\n the name of an MS-DOS  application.  If  you are running");
  67.          printf("\n Windows 95 or NT you can run MS-DOS commands or the name");
  68.          printf("\n of a Windows applications like 'NOTEPAD.EXE'.           ");
  69.          printf("\n Enter the command to run: "                              );
  70.          get_string(strBuffer);
  71.          if (strlen(strBuffer))
  72.          {
  73.             printf("\n  About to run the '%s' command.\n", strBuffer);
  74.             printf("\n  Hit any key to run the command.....\n");
  75.             getch();
  76.             spawn(strBuffer);
  77.          }
  78.          else
  79.          {
  80.             printf("\n  No command was supplied!\n");
  81.          }
  82.       }
  83.       else if (sNumber == 4)
  84.       {
  85.          printf("\n Loop Test Case                                          ");
  86.          printf("\n --------------                                          ");
  87.          printf("\n This macro language supports the 'if', 'for' and 'while'");
  88.          printf("\n control  statements.  Input the  number of time you want");
  89.          printf("\n the 'for' and 'while' loop test to run: "                );
  90.          get_string(strBuffer);
  91.          sNumber = atoi(strBuffer);
  92.       
  93.          printf("\n Running 'For' Loop Test");
  94.          for (i = 0; i < sNumber; ++i)
  95.          {
  96.             printf("\n For Loop Number: '%d'", i);
  97.          }
  98.       
  99.          printf("\n\n Running 'While' Loop Test");
  100.          i = 0;
  101.          while (i < sNumber)
  102.          {
  103.             printf("\n While Loop Number: '%d'", i);
  104.             ++i;
  105.          }
  106.  
  107.          printf("\n");
  108.       }
  109.       else if (sNumber == 5)
  110.       {
  111.          printf("\n String Test Case                                  ");
  112.          printf("\n ----------------                                  ");
  113.          printf("\n This macro language supports a string type as well");
  114.          printf("\n the standard integer and char types.\n            ");
  115.          printf("\n Input any string text: "                           );
  116.          get_string(strBuffer);
  117.          printf("\n The string value you supplied was: '%s'\n", strBuffer);
  118.          strupr(strBuffer);
  119.          printf("\n The string value in upper case is: '%s'\n", strBuffer);
  120.          strlwr(strBuffer);
  121.          printf("\n The string value in lower case is: '%s'\n", strBuffer);
  122.          sLength = strlen(strBuffer);
  123.          printf("\n The string length is: '%d'\n", sLength);
  124.       }
  125.       else if (sNumber == 6)
  126.       {
  127.          // This quits the macro
  128.          return 0;
  129.       }
  130.       else
  131.       {
  132.          printf("\n Unknown command entered!\n");
  133.       }
  134.  
  135.       printf("\n Hit the space bar to continue.....");
  136.       getch();
  137.    }
  138. }
  139.  
  140.