File indexing completed on 2024-04-14 14:32:39

0001 
0002 #include "kmuddyvars.h"
0003 
0004 int main ()
0005 {
0006   char variable[201];
0007     char x[251];
0008     initVariableSocket ();
0009   
0010     if (setVariable ("test", "This is some test. :)"))
0011         puts ("say Value of variable test has been set.");
0012     else
0013         puts ("say Failed to set variable test.");
0014   
0015     fflush(stdout);
0016     
0017     getVariable ("test", variable, 200);
0018     strcpy (x, "say So, value of test = ");
0019     strcat (x, variable);
0020     //IMPORTANT: keep in mind that the variable may no longer have the same
0021     //value when the command is sent
0022     puts (x);
0023 
0024     if (unsetVariable ("test"))
0025         puts ("say The variable test is no longer set.");
0026     else
0027         puts ("say Failed to unset variable test.");
0028 
0029     fflush(stdout);
0030 
0031 
0032     setVariable ("number", "4");
0033     puts ("say variable number has been set to $number.");
0034     //we need to sleep, so that the output is displayed correctly
0035     fflush(stdout);
0036     incVariable ("number", 10);
0037     puts ("say variable number has been increased by 10, thus it's now $number.");
0038     //we need to sleep, so that the output is displayed correctly
0039     fflush(stdout);
0040     decVariable ("number", 7);
0041     puts ("say decreased test by 7, it's now $number.");
0042     fflush(stdout);
0043     provideResource("xxx");
0044     provideResource("xxx");
0045     puts ("say Provided two units of resource XXX.");
0046     int i;
0047     for (i = 0; i < 3; i++)
0048     {
0049     char r = requestResource("xxx");
0050         if (r)
0051             puts ("say Requesting resource XXX - OKAY");
0052         else
0053             puts ("say Requesting resource XXX - FAILED");
0054     }
0055     
0056     closeVariableSocket ();
0057     return 0;
0058 }
0059