Dealing with values

Previous: Working with requests ] [ Top:  ] [ Next: Working with the enactment history ]



set: setting named values
To set a value, we have to find and load the specified datasheet, then call wftk_value_set to set the value.
 
if (argsleft < 4) {
   printf ("wftk set: repository and ID of the datasheet, the value name, and the value are all required.\n");
   exit (1);
}

datasheet = wftk_process_load (session, PERIOD_TO_NULL(argv[argp]), argv[argp+1]); argp++; argp++;
if (!datasheet) {
   printf ("Datasheet repository %s can't find datasheet %s", argv[argp-2], argv[argp-1]);
   exit (1);
}
wftk_value_set (session, datasheet, argv[argp], argv[argp+1]); argp++; argp++;
wftk_process_save (session, datasheet);
printf ("%s = %s\n", argv[argp-2], argv[argp-1]);


get: getting named values
Getting a value is pretty much the same thing, except that we don't have to save the datasheet afterwards.
 
if (argsleft < 3) {
   printf ("wftk get: repository and ID of the datasheet and the value name are all required.\n");
   exit (1);
}

datasheet = wftk_process_load (session, PERIOD_TO_NULL(argv[argp]), argv[argp+1]); argp++; argp++;
if (!datasheet) {
   printf ("Datasheet repository %s can't find datasheet %s", argv[argp-2], argv[argp-1]);
   exit (1);
}
printf ("%s\n", wftk_value_get (session, datasheet, argv[argp++]));


values: listing named values
Listing the values in a datasheet is very similar to listing tasks.
 
if (argsleft < 2) {
   printf ("wftk list: repository and ID of the datasheet are required.\n");
   exit (1);
}

datasheet = wftk_process_load (session, PERIOD_TO_NULL(argv[argp]), argv[argp+1]); argp++; argp++;
if (!datasheet) {
   printf ("Datasheet repository %s can't find datasheet %s", argv[argp-2], argv[argp-1]);
   exit (1);
}

list = xml_create ("list");
wftk_value_list (session, datasheet, list);
mark = xml_firstelem (list);
if (!mark) {
   printf ("No values set.\n");
} else {
   while (mark) {
      printf ("%s = %s", xml_attrval (mark, "id"), xml_attrval (mark, "value"));
      printf ("\n");
      mark = xml_nextelem (mark);
   }
}


html: getting HTML for a named value
Getting HTML is a whole lot like getting the regular value.
 
if (argsleft < 3) {
   printf ("wftk get: repository and ID of the datasheet and the value name are all required.\n");
   exit (1);
}

datasheet = wftk_process_load (session, PERIOD_TO_NULL(argv[argp]), argv[argp+1]); argp++; argp++;
if (!datasheet) {
   printf ("Datasheet repository %s can't find datasheet %s", argv[argp-2], argv[argp-1]);
   exit (1);
}
mark = wftk_value_html (session, datasheet, argv[argp++]);
if (mark) {
   xml_write (stdout, mark);
   printf ("\n");
   xml_free (mark);
}


htmlblank: getting a blank field
And getting blank HTML is exactly the same.
 
if (argsleft < 3) {
   printf ("wftk get: repository and ID of the datasheet and the value name are all required.\n");
   exit (1);
}

datasheet = wftk_process_load (session, PERIOD_TO_NULL(argv[argp]), argv[argp+1]); argp++; argp++;
if (!datasheet) {
   printf ("Datasheet repository %s can't find datasheet %s", argv[argp-2], argv[argp-1]);
   exit (1);
}
mark = wftk_value_htmlblank (session, datasheet, argv[argp++]);
if (mark) {
   xml_write (stdout, mark);
   printf ("\n");
   xml_free (mark);
}
Previous: Working with requests ] [ Top:  ] [ Next: Working with the enactment history ]


This code and documentation are released under the terms of the GNU license. They are additionally copyright (c) 2000, Vivtek. All rights reserved except those explicitly granted under the terms of the GNU license.