key llGetNotecardLine(string name, integer line)

This function fetches line number of notecard name and returns the data through the dataserver event. The line count starts at zero. If the requested line is past the end of the notecard, the dataserver event will return the constant EOF (“End Of File”) string. You can get the number of lines in a notecard with llGetNumberOfNotecardLines. The key returned by llGetNotecardLine is a unique identifier which will be supplied to the dataserver event as the queryid parameter.

name can be either a string containing the name of a notecard in the object’s inventory, or a key pointing to a notecard (that can be anywhere and doesn’t have to reside in the object). In the latter case. you should keep in mind that any time you edit and save such a notecard, it will get a new key.

If name is not a valid notecard, or if the notecard is empty, the object will print to the Script Errors/Warning window, “Couldn’t find notecard NAME” where “NAME” is the name of the invalid notecard.

Note that lines longer than 255 characters will be truncated without any indication that this has been done.

Requests from notecards that contain embedded inventory items will always result in EOF, regardless of the line being requested.

Note: This function delays the script for 0.1 seconds.

Example:

// Read out a complete notecard from the object's inventory.
string gName;    // name of a notecard in the object's inventory
integer gLine = 0;        // current line number
key gQueryID; // id used to identify dataserver queries

default {
    state_entry() {
        gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventory
        gQueryID = llGetNotecardLine(gName, gLine);    // request first line
    }

    dataserver(key query_id, string data) {
        if (query_id == gQueryID) {
            if (data != EOF) {    // not at the end of the notecard
                llSay(0, (string)gLine+": "+data);    // output the line
                ++gLine;                // increase line count
                gQueryID = llGetNotecardLine(gName, gLine);    // request next line
            }
        }
    }
}
/////
//  Generic Multi Notecard reader by Brangus Weir
//  Given freely and published on wiki.secondlife.com
//
// This script will read three note cards and store the results into 3 lists.
// It can be modified and extended to as many cards as you'd like to read. 
//
list gOneCard;  // All the lines from from the first card
list gTwoCard;    // All the lines from from the second card
list gThreeCard;   // All the lines from from the third card

string gsCardOneName = "One";  //Set these to the name of the inventory item.
string gsCardTwoName = "Two";
string gsCardThreeName = "Three";

//Temporary variables for processing
string g_sNoteCardName; // Name of the card to be read.
list g_lTempLines;  // The resulting data pushed into a list
integer g_iLine;    // The line count for the card reader
key g_kQuery;       // The key of thge card being read


initialize(string _action) {

 

This script will check the UUID of the notecards in the object’s contents on an inventory change and tell you which one was updated, it also checks if any of them were deleted.

//written by Ruthven Willenov, added to lslwiki 9/23/2009
// corrected by Omei Qunhua 8-Mar-2012
list notes;
list ids;
integer note = INVENTORY_NOTECARD;

default
{
    state_entry()
    {
        integer tot = llGetInventoryNumber(note);
        integer i = 0;
        for(i;i < tot;++i)
            {
                string name = llGetInventoryName(note,i);
                key id = llGetInventoryKey(name);
                integer index = llListFindList(notes, [name]);      // OmeiQ
                if(index = -1 )
                {
                    notes += name;
                    ids += id;
                    llOwnerSay("Added notecard named: " + name);
                }
            }
        }
    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        {
            integer tot = llGetInventoryNumber(note);
            integer i = 0;
            for(i;i < tot;++i)
            {
                string name = llGetInventoryName(note,i);
                key id = llGetInventoryKey(name);
                integer index = llListFindList(notes,(list)name);
                if(index == -1 )
                {
                    notes += name;
                    ids += id;
                    llOwnerSay("Added notecard named: " + name);
                }
                else
                if(index >= 0)
                {
                    if(llList2Key(ids,index) != id)
                    {
                        ids = llDeleteSubList(ids,index,index);
                        ids = llListInsertList(ids,(list)id,index);
                        llOwnerSay(name + " was updated");
                    }
                }
            }
            integer len = llGetListLength(notes)-1;
            for(len; len >= 0; --len)
            {
                string name = llList2String(notes,len);
                integer type = llGetInventoryType(name);
                if(type == -1)
                {
                    llOwnerSay(name + " was removed.");
                    notes = llDeleteSubList(notes,len,len);
                    ids = llDeleteSubList(ids,len,len);
                }
            }                
        }
    }
                        
}

Q: How do I write to a notecard?
A: In LSL, you can not.  In OSSL, you can using osMakeNotecard.

Q: What happens if I create a notecard, don’t edit and save it, but place it in the object and then try to run llGetNotecardLine on it?
A: The same thing as if you passed an invalid name: the object will say, “Couldn’t find notecard NAME” where “NAME” is the name of the invalid notecard. Nothing will be returned to the script, and it will be as if llGetNotecardLine was never called.
 
Q: So what do I do then? How does my script know what to do if there’s no way to tell it whether or not the notecard is empty?
A: Try adding a timeout using a timer, or use a second object containing a listener to reply with a message indicating the notecard was empty or not present.
 
Q: Is there some way to get around the 255-character line limit?
A: No. The best you can do is to check the length of the resulting string in the dataserver event using llStringLength to see if it reaches the maximum, then from that, assume the line has been truncated. The problem with doing this is that your script can’t actually do anything about it, save for suggesting to the user that they may wish to examine the line in question to determine if anything important is in there. Further, there’s the very real possibility of false positives in non-truncated lines that just happen to be 255 characters long.
 
Q: So I guess that means there’s no way to conclusively determine whether a line’s been truncated, huh?
A: Nope, sorry.