llGetNotecardLineSync

From Second Life Wiki
Jump to navigation Jump to search

Summary

Function: string llGetNotecardLineSync( string name, integer line );

Requests the line line of the notecard name from the dataserver.
Returns the string containing the text of the requested line from the notecard.

• string name a notecard in the inventory of the prim this script is in or a UUID of a notecard
• integer line Line number in a notecard (the index starts at zero).

line does not support negative indexes. If line is past the end of the notecard EOF is returned by the dataserver.

Specification

This function returns a string containing the requested line from a notecard in prim inventory. If the notecard does not exist it returns the constant NAK and will shout a message to the debug channel. If the notecard has not been previously cached on the simulator it will return the NAK constant.

It is not safe to assume a notecard has been previously cached. Data for a previously cached notecard may be dropped from the cache at any time, especially on a busy server.

Caveats

  • If line is out of bounds the script continues to execute without an error message.
  • If name is missing from the prim's inventory and it is not a UUID or it is not a notecard then an error is shouted on DEBUG_CHANNEL.
  • If name is a UUID then there are no new asset permissions consequences for the object.
    • The resulting object develops no new usage restrictions that might have occurred if the asset had been placed in the prims inventory.
  • If name is a new empty notecard (never saved) then an error "Couldn't find notecard ~NAME~" (~NAME~ being the value of name) will be shouted on the DEBUG_CHANNEL. This is because until a notecard is saved for the first time, it does not exist as an asset only as an inventory placeholder.
  • If notecard contains embedded inventory items (such as textures and landmarks), EOF will be returned, regardless of the line requested.
  • If the requested line is longer than 1024 bytes the returned string will be truncated to the first 1024 bytes of the line.
All Issues ~ Search JIRA for related Bugs

Examples

string NOTECARD_NAME = "notecard";
key READ_KEY = NULL_KEY;

default
{

    touch_start(integer total_number)
    {
        READ_KEY = llGetNumberOfNotecardLines(NOTECARD_NAME);
    }
    
    dataserver(key request, string data)
    {
        if (request == READ_KEY)
        {
            integer count = (integer)data;
            integer index;
            
            for (index = 0; index < count; ++index)
            {
                string line = llGetNotecardLineSync(NOTECARD_NAME, index);
                if (line == NAK)
                {
                    llSay(0, "---NAK---");
                }
                else if (line == EOF)
                {
                    llSay(0, "---EOF---");
                }
                else
                {
                    llSay(0, line);
                }
            }
        }
    }
}

See Also

Deep Notes

Search JIRA for related Issues

Signature

function string llGetNotecardLineSync( string name, integer line );