Difference between revisions of "LlKeysKeyValue"

From Second Life Wiki
Jump to navigation Jump to search
(Example code would not compile due to a number of issues. I've attempted to address those issues)
m (too many Key's)
Line 30: Line 30:
         trans = llKeysKeyValue(0, 10);
         trans = llKeysKeyValue(0, 10);
     }
     }
     dataserver(key t, string value)
     dataserver(key t, string value)
     {
     {
         if (t == trans)
         if (t == trans)
         {
         {
             // our llKeyKeyKeyValue transaction is done
             // our llKeysKeyValue transaction is done
             list result = llCSV2List(value);
             list result = llCSV2List(value);
             if (llList2Integer(result, 0) == 1)
             if (llList2Integer(result, 0) == 1)

Revision as of 17:21, 16 August 2014

Summary

Function: key llKeysKeyValue( integer first, integer count );

Start an asynchronous transaction to request a number of keys.
Returns a handle (a key) that can be used to identify the corresponding dataserver event to determine if this command succeeded or failed.

• integer first Zero-based index of the first key to retrieve
• integer count Number of keys to retriever

This function will attempt to retrieve the number of keys requested but may return less if there are not enough to fulfill the full amount requested or if the list is too large. The order keys are returned is not guaranteed but is stable between subsequent calls as long as no keys are added or removed.
The error XP_ERROR_KEY_NOT_FOUND is returned if there index given is greater than or equal to the number of keys.

Specification

Dataserver

The dataserver callback parameters are:

String Components
• integer success A boolean specifying if the transaction succeeded (1) or not (0).
• integer error An XP_ERROR_* flag that describes why the operation failed.
• list keys A list of keys (strings) used in the key-value store

Examples

<lsl>key trans; default {

   state_entry()
   {
       // retrieve the first 10 keys
       trans = llKeysKeyValue(0, 10);
   }
   dataserver(key t, string value)
   {
       if (t == trans)
       {
           // our llKeysKeyValue transaction is done
           list result = llCSV2List(value);
           if (llList2Integer(result, 0) == 1)
           {
               llSay(0, "Keys retrieved: "+(string)llGetSubString(value, 2, -1));
           }
           else if (llList2Integer(result, 1) == XP_ERROR_KEY_NOT_FOUND)
           {
               // no more keys
               llSay(0, "No more keys" );
           }
           else
           {
               // keys request failed
               llSay(0, "Key-value failed to request keys: " + llGetExperienceErrorMessage(llList2Integer(result, 1)) );
           }
       } 
   }
}</lsl>

Deep Notes

Search JIRA for related Issues

Signature

function key llKeysKeyValue( integer first, integer count );