Read Notecard Sequentially

Written by Kitsune
key notecard1ReadKey;
key notecard2ReadKey;
string notecard1 = "Notecard 1";
string notecard2 = "Notecard 2";
integer line1Counter;
integer line2Counter;
list notecard1Data;
list notecard2Data;
 
default
{
    touch_start(integer total_number)
    {
        line1Counter = 0;
        line2Counter = 0;
        notecard1Data = [];
        notecard2Data = [];
 
        llSay(0, "Reading: " + notecard1);
        notecard1ReadKey = llGetNotecardLine(notecard1, line1Counter);
    }
    dataserver(key queryid, string data)
    {
        if (queryid == notecard1ReadKey)
        {
            if (data != EOF)
            {
                notecard1Data += data;
                line1Counter++;
                notecard1ReadKey = llGetNotecardLine(notecard1, line1Counter);
            }
            else
            {
                llSay(0, "Reading: " + notecard2);
                notecard2ReadKey = llGetNotecardLine(notecard2, line2Counter);
            }
        }
        if (queryid == notecard2ReadKey)
        {
            if (data != EOF)
            {
                notecard2Data += data;
                line2Counter++;
                notecard2ReadKey = llGetNotecardLine(notecard2, line2Counter);
            }
            else
            {
                integer x;
 
                llSay(0, "Displaying Notecard Data...");
                llSay(0, notecard1 + ":");
                for (x = 0; x < llGetListLength(notecard1Data); x++)
                {
                    llSay(0, "Line #" + (string)x + ": " + llList2String(notecard1Data, x));
                }
                llSay(0, notecard2 + ":");
                for (x = 0; x < llGetListLength(notecard2Data); x++)
                {
                    llSay(0, "Line #" + (string)x + ": " + llList2String(notecard2Data, x));
                }
            }
        }
    }
}