home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sompar.zip / SOM / CLIENT.CPP next >
C/C++ Source or Header  |  1993-12-19  |  5KB  |  248 lines

  1. //
  2. // Project: Digitalk Parts like Toolbar and SOMObjects Containers Demo
  3. // File:    Client.cpp
  4. // Author:  Stewart Hyde
  5. // Created: Dec   18, 1993
  6. // Updated: Dec   18, 1993
  7. //
  8. // Description:
  9. //        This is a test program for DSOM Part.dll
  10. //
  11.  
  12.  
  13. #include <stdio.h>
  14. #include <somd.xh>
  15. #include <Part.xh>
  16.  
  17. #define checkEv(ev) ((ev)->_major != NO_EXCEPTION)
  18.  
  19. void ErrorReport(Environment *ev)
  20. {
  21.     somPrintf("Error Occured\n");
  22.     // --------------------------------------------------------------------
  23.     //  Cleanup Local and DSOM enviroments
  24.     // --------------------------------------------------------------------
  25.  
  26.     SOMD_Uninit(ev);
  27.     SOM_DestroyLocalEnvironment(ev);
  28. }
  29.  
  30. PrintStatus(long x, long y, long Index, long Count)
  31. {
  32.     somPrintf("Set #%d, Function #%d, Index= %d, Count = %d\n",x,y,Index,Count);
  33. }
  34.  
  35.  
  36. int main(int argc, char *argv[])
  37. {
  38.       Environment *ev;
  39.     Part *part = (Part *) NULL;
  40.     Part *part2 = (Part *) NULL;
  41.     long nIndex, nCount;
  42.  
  43.     // --------------------------------------------------------------------
  44.     //  Initialize Local and DSOM enviroments
  45.     // --------------------------------------------------------------------
  46.  
  47.       ev = SOM_CreateLocalEnvironment();
  48.      SOMD_Init(ev);    
  49.  
  50.     // --------------------------------------------------------------------
  51.     //  Register Part Class with SOMClassMgr
  52.     // --------------------------------------------------------------------
  53.  
  54.     PartNewClass(0,0);    
  55.  
  56.  
  57.     // --------------------------------------------------------------------
  58.     //  Allocate a Part class
  59.     // --------------------------------------------------------------------
  60.  
  61.     part = (Part *) SOMD_ObjectMgr->somdNewObject(ev, "Part", NULL);
  62.     if (checkEv(ev))
  63.     {
  64.         ErrorReport(ev);
  65.         return(-1);
  66.     }    
  67.  
  68.     // --------------------------------------------------------------------
  69.     //  Allocate a Part class
  70.     // --------------------------------------------------------------------
  71.  
  72.     part2 = (Part *) SOMD_ObjectMgr->somdNewObject(ev, "Part", NULL);
  73.     if (checkEv(ev))
  74.     {
  75.         ErrorReport(ev);
  76.         return(-1);
  77.     }    
  78.  
  79.     part->Add(ev, 1, 1, &nIndex, &nCount);
  80.     if (checkEv(ev))
  81.     {
  82.         ErrorReport(ev);
  83.         return(-1);
  84.     }    
  85.     else
  86.         PrintStatus(1,1,nIndex,nCount);
  87.  
  88.     part2->Add(ev, 1, 1, &nIndex, &nCount);
  89.     if (checkEv(ev))
  90.     {
  91.         ErrorReport(ev);
  92.         return(-1);
  93.     }    
  94.     else
  95.         PrintStatus(1,1,nIndex,nCount);
  96.  
  97.  
  98.     part->Update(ev, 1, 1, &nIndex, &nCount);
  99.     if (checkEv(ev))
  100.     {
  101.         ErrorReport(ev);
  102.         return(-1);
  103.     }    
  104.     else
  105.         PrintStatus(1,1,nIndex,nCount);
  106.  
  107.     part->Add(ev, 1, 2, &nIndex, &nCount);
  108.     if (checkEv(ev))
  109.     {
  110.         ErrorReport(ev);
  111.         return(-1);
  112.     }    
  113.     else
  114.         PrintStatus(1,2,nIndex,nCount);
  115.  
  116.     part2->Add(ev, 1, 2, &nIndex, &nCount);
  117.     if (checkEv(ev))
  118.     {
  119.         ErrorReport(ev);
  120.         return(-1);
  121.     }    
  122.     else
  123.         PrintStatus(1,2,nIndex,nCount);
  124.  
  125.  
  126.     part->Add(ev, 2, 1, &nIndex, &nCount);
  127.     if (checkEv(ev))
  128.     {
  129.         ErrorReport(ev);
  130.         return(-1);
  131.     }    
  132.     else
  133.         PrintStatus(2,1,nIndex,nCount);
  134.  
  135.     part->Update(ev, 2, 1, &nIndex, &nCount);
  136.     if (checkEv(ev))
  137.     {
  138.         ErrorReport(ev);
  139.         return(-1);
  140.     }    
  141.     else
  142.         PrintStatus(2,1,nIndex,nCount);
  143.  
  144.     part->Update(ev, 1, 2, &nIndex, &nCount);
  145.     if (checkEv(ev))
  146.     {
  147.         ErrorReport(ev);
  148.         return(-1);
  149.     }    
  150.     else
  151.         PrintStatus(1,2,nIndex,nCount);
  152.  
  153.  
  154.     part->Update(ev, 1, 1, &nIndex, &nCount);
  155.     if (checkEv(ev))
  156.     {
  157.         ErrorReport(ev);
  158.         return(-1);
  159.     }    
  160.     else
  161.         PrintStatus(1,1,nIndex,nCount);
  162.  
  163.     part2->Update(ev, 1, 1, &nIndex, &nCount);
  164.     if (checkEv(ev))
  165.     {
  166.         ErrorReport(ev);
  167.         return(-1);
  168.     }    
  169.     else
  170.         PrintStatus(1,1,nIndex,nCount);
  171.  
  172.     
  173.     part->Update(ev, 1, 2, &nIndex, &nCount);
  174.     if (checkEv(ev))
  175.     {
  176.         ErrorReport(ev);
  177.         return(-1);
  178.     }    
  179.     else
  180.         PrintStatus(1,2,nIndex,nCount);
  181.  
  182.     part->Update(ev, 1, 2, &nIndex, &nCount);
  183.     if (checkEv(ev))
  184.     {
  185.         ErrorReport(ev);
  186.         return(-1);
  187.     }    
  188.     else
  189.         PrintStatus(1,2,nIndex,nCount);
  190.  
  191.     part2->Update(ev, 1, 2, &nIndex, &nCount);
  192.     if (checkEv(ev))
  193.     {
  194.         ErrorReport(ev);
  195.         return(-1);
  196.     }    
  197.     else
  198.         PrintStatus(1,2,nIndex,nCount);
  199.  
  200.     part->Add(ev, 2, 2, &nIndex, &nCount);
  201.     if (checkEv(ev))
  202.     {
  203.         ErrorReport(ev);
  204.         return(-1);
  205.     }    
  206.     else
  207.         PrintStatus(2,2,nIndex,nCount);
  208.  
  209.     part->Add(ev, 2, 3, &nIndex, &nCount);
  210.     if (checkEv(ev))
  211.     {
  212.         ErrorReport(ev);
  213.         return(-1);
  214.     }    
  215.     else
  216.         PrintStatus(2,3,nIndex,nCount);
  217.  
  218.  
  219.     part->Add(ev, 2, 4, &nIndex, &nCount);
  220.     if (checkEv(ev))
  221.     {
  222.         ErrorReport(ev);
  223.         return(-1);
  224.     }    
  225.     else
  226.         PrintStatus(2,4,nIndex,nCount);
  227.  
  228.  
  229.     part2->Add(ev, 2, 5, &nIndex, &nCount);
  230.     if (checkEv(ev))
  231.     {
  232.         ErrorReport(ev);
  233.         return(-1);
  234.     }    
  235.     else
  236.         PrintStatus(2,5,nIndex,nCount);
  237.  
  238.  
  239.     // --------------------------------------------------------------------
  240.     //  Cleanup Local and DSOM enviroments
  241.     // --------------------------------------------------------------------
  242.  
  243.     SOMD_Uninit(ev);
  244.     SOM_DestroyLocalEnvironment(ev);
  245.  
  246.     return(0);
  247. }
  248.