WritePropertyValue
Writes a value to a property of type Item (For cross-platform functionality, see Developing NLMs with Cross-Platform Functions ( NDK: NLM Development Concepts, Tools, and Functions) and call NWWritePropertyValue )
#include <\nlm\nit\nwbindry.h>
int WritePropertyValue (
char *objectName,
WORD objectType,
char *propertyName,
int segmentNumber,
BYTE *propertyValue,
BYTE moreSegments);
The objectName, objectType, and propertyName parameters must uniquely identify a bindery object’s property and must not contain wildcard characters. The objectName can be from 1 to 48 characters long, including the NULL terminator. The propertyName can be from 1 to 16 characters long, including the NULL terminator. Only printable characters can be used. Slashes, backslashes, colons, semicolons, commas, asterisks, and question marks are prohibited.
The segmentNumber parameter should be set to 1 to write the first data segment. When creating a property value, the segments must be written in sequential order. Before segment n can be written, all segments from 1 to n-1 must have been written. To write property data of more than one segment (128 bytes), this function should be called iteratively. Once all segments of a property value have been established, segments can be written at random.
When writing the last segment of a property value the moreSegments flag should be set to zero. The bindery truncates the property value and discards extra segments if the moreSegments flag is 0 and the bindery has segments beyond the segment written. Property values should be kept to a single segment (128 bytes) to improve bindery efficiency.
The bindery makes no attempt to coordinate activities between multiple entities that might be reading or writing data to a single property. This means that one entity might read a partially-updated property and get inconsistent data, if the property’s data extends across multiple segments. If this presents a problem, coordination on reads and writes must be handled by application programs. Logical record locks can be used to coordinate activities among applications.
Do not use this function to write values to set properties. Instead, call AddBinderyObjectToSet.
#include <stdio.h>
#include <\nlm\nit\nwbindry.h>
main()
{
int completionCode, segmentNumber;
char objectName[48], propertyName[16];
WORD objectType;
BYTE propertyValue[128], moreSegments;
printf ("\n\n");
printf ("Enter Object Name —> ");
scanf ("%s", objectName);
printf ("\nEnter Object Type —> ");
scanf ("%d", &objectType);
printf ("\nEnter Property Name —> ");
scanf ("%s", propertyName);
printf ("\nEnter Segment Number —> ");
scanf ("%d", &segmentNumber);
printf ("\nEnter Property Value —> ");
scanf ("%d", &propertyValue);
printf ("\nEnter More Segments —> ");
scanf ("%d", &moreSegments);
completionCode = WritePropertyValue (objectName,
objectType, propertyName, segmentNumber,
propertyValue, moreSegments);
printf ("\n\n\n");
if (completionCode)
{
if (completionCode == 150)
printf ("SERVER OUT OF MEMORY\n");
else if (completionCode == 232)
printf ("NO ITEM PROPERTY\n");
else if (completionCode == 236)
printf ("NO SUCH SEGMENT\n");
else if (completionCode == 240)
printf ("WILDCARD NOT ALLOWED\n");
else if (completionCode == 241)
printf ("INVALID BINDERY SECURITY\n");
else if (completionCode == 248)
printf ("NO PROPERTY WRITE PRIVILEGE\n");
else if (completionCode == 251)
printf ("NO SUCH PROPERTY\n");
else if (completionCode == 252)
printf ("NO SUCH OBJECT\n");
else if (completionCode == 254)
printf ("SERVER BINDERY LOCKED\n");
else if (completionCode == 255)
printf ("BINDERY FAILURE\n");
else
printf ("completionCode = %d\n", completionCode);
}
else
printf (" SUCCESSFULLY COMPLETED...\n");
}