home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / mltiscop / tutor.c < prev    next >
C/C++ Source or Header  |  1989-07-28  |  2KB  |  112 lines

  1. /*  Logitech MultiScope Debugger Tutorial Program
  2.  *  Copyright (C) 1989 Logitech, Inc.
  3.  *
  4.  *  This is the main 'C' module for TUTOR.C.
  5.  */
  6.  
  7. #include <stdio.h>
  8. #include <malloc.h>
  9. #include <string.h>
  10. #include <os2def.h>
  11. #define INCL_DOS
  12. #include <bse.h>
  13.  
  14. struct DataRec {           
  15.   struct DataRec far *left, far *right;
  16.   int value;
  17.   int uc;
  18.   char dataString[129];
  19. }
  20.  
  21. /* import binary tree structure functions */
  22. extern InitInsert();    
  23. extern Insert(struct DataRec far *);
  24. extern Print();    
  25. extern unsigned int Fibonacci(unsigned int);
  26.  
  27. /* import graphical data & functions */
  28. extern llrasmain();
  29.  
  30.  
  31. VOID FAR thread_1();
  32.  
  33. static int count=0;
  34.  
  35. struct ArrayRec {
  36.   int data;
  37.   double realval;
  38. } array[128];
  39.  
  40. main()
  41. {
  42.     int val, max, i;
  43.     PBYTE th1Stack, th2Stack;
  44.     TID tidTh1, tidTh2;
  45.     
  46.     printf("Logitech MultiScope Tutorial Program\n");
  47.     printf("Enter \"MSDEMO\" to begin!\n");
  48.  
  49.     th1Stack = malloc(4000);    /* create a new thread   */
  50.     th1Stack += 4000;
  51.  
  52.     DosCreateThread((PFNTHREAD)thread_1, &tidTh1, th1Stack);
  53.  
  54.     /* make graphical data structure */
  55.     llrasmain();
  56.     
  57.     /* init sort tree */
  58.     InitInsert();
  59.     
  60.     DosSleep(500L);
  61.     
  62.     /* build sort tree */
  63.     ChooseMe(1,"MultiScope",3);
  64.     ChooseMe(7,"DBX",3);
  65.     ChooseMe(4,"SYMDEB",3);
  66.     ChooseMe(100,"GDBX",3);
  67.     ChooseMe(12,"GDB",3);
  68.     ChooseMe(55,"CodeView",3);
  69.     ChooseMe(99,"Turbo Debugger",3);
  70.     ChooseMe(43,"DEBUG",3);
  71.  
  72.     /* print result */
  73.     Print();  
  74.     
  75.     /* exit */
  76.     exit(0);
  77. }
  78.  
  79. ChooseMe(i, s, j)
  80. int i;
  81. char *s;
  82. int j;
  83. {
  84.   struct DataRec *new;
  85.   float d;
  86.   
  87.   d = j / 2;
  88.   new = malloc(sizeof(struct DataRec));
  89.   new->value = i;
  90.   strcpy(new->dataString, s);
  91.   Insert(new);
  92.   array[count].realval = d;
  93.   array[count].data = i;
  94.   BreakMe();
  95. }
  96.  
  97. BreakMe()
  98. {
  99.   ++count;
  100. }
  101.  
  102. VOID FAR thread_1()
  103. {
  104.     int val;
  105.  
  106.     while (1) {
  107.         val = Fibonacci(500);    /* calculate Fibonacci numbers below 500 */
  108.         DosSleep(50L);
  109.     }
  110. }
  111.  
  112.