home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / CPAL.ZIP;1 / TEST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-21  |  2.3 KB  |  145 lines

  1. #include <windows.h>
  2. #include "paluser.hpp"
  3.  
  4.  
  5.  
  6. //
  7. // Example of setting the value of a number.
  8. //
  9.  
  10. extern "C" void EXPPLUS setNum(AnyType nm)
  11. {
  12.     pxSetValue(nm, (long double) 3.12);
  13. }
  14.  
  15. //
  16. // Example of setting the value of a string.
  17. //
  18. extern "C" void EXPPLUS setString(AnyType str)
  19. {
  20.     pxSetValue(str, "NewValue");
  21. }
  22.  
  23. //
  24. // Example of setting the value of a date.
  25. //
  26. extern "C" void EXPPLUS setDate(AnyType da)
  27. {
  28.     pxDate date;
  29.  
  30.     date.day   = 15;
  31.     date.month = 1;
  32.     date.year  = 1993;
  33.  
  34.     pxSetValue(da, &date);
  35.  
  36. }
  37.  
  38. //
  39. // Example of setting/retreiving the value of a record element.
  40. //
  41. extern "C" void EXPPLUS getRecordInfo(Record rec)
  42. {
  43.     AnyType pd;
  44.     long double x;
  45.  
  46.     if (rec)
  47.         {
  48.         //
  49.         // Given the record pointer, fectch the Pal datum
  50.         // for the particular field.
  51.         //
  52.  
  53.         pd = pxGetData(rec, "Item1");
  54.  
  55.         if (pd)
  56.             {
  57.             //
  58.             // Convert the PalDatum to a C++ type.
  59.             pxGetValue(pd, &x);
  60.  
  61.             //
  62.             // Change the value. It will also change in rec.
  63.            //
  64.             pxSetValue(pd, (long double) 3.12);
  65.             }
  66.         }
  67. }
  68.  
  69.  
  70. //
  71. // Example of setting/retreiving the value of an array element.
  72. //
  73. extern "C" void EXPPLUS getArrayInfo(Array ar)
  74. {
  75.     AnyType pd;
  76.     long double x;
  77.  
  78.     if (ar)
  79.         {
  80.         //
  81.         // Given the array pointer, fectch the Pal datum
  82.         // for the particular field. (Indexes start at 0 NOT 1).
  83.         //
  84.  
  85.         pd = pxGetData(ar, 0);
  86.  
  87.         if (pd)
  88.             {
  89.             //
  90.             // Convert the PalDatum to a C++ type.
  91.             pxGetValue(pd, &x);
  92.  
  93.             //
  94.             // Change the value. It will also change in ar.
  95.            //
  96.             pxSetValue(pd, (long double) 3.12);
  97.             }
  98.         }
  99. }
  100.  
  101. //
  102. // Example of setting/retreiving the value of a dynArray element.
  103. //
  104. extern "C" void EXPPLUS getDynArrayInfo(DynArray ar)
  105. {
  106.     AnyType pd;
  107.     long double x;
  108.  
  109.     if (ar)
  110.         {
  111.         pd = pxGetData(ar, "Fred");
  112.  
  113.         if (pd)
  114.             {
  115.             //
  116.             // Convert the PalDatum to a C++ type.
  117.             pxGetValue(pd, &x);
  118.  
  119.             //
  120.             // Change the value. It will also change in ar.
  121.            //
  122.             pxSetValue(pd, (long double) 3.12);
  123.             }
  124.         }
  125. }
  126.  
  127.  
  128.  
  129.  
  130. //
  131. // Calling back to ObjectPal via an action
  132. //
  133. extern "C" void EXPPLUS uiCallBack(UIObject ui)
  134. {
  135.     pxAction(ui, 1);
  136. }
  137.  
  138. //
  139. // Posting an action back to ObjectPal via an action
  140. //
  141. extern "C" void EXPPLUS uiPostBack(UIObject ui)
  142. {
  143.     pxPostAction(ui, 2);
  144. }
  145.