Jump to content

Reading from a notecard


Jade Tachikawa
 Share

You are about to reply to a thread that has been inactive for 1025 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi there,

 

I've not done much scripting for ages but I'm working on an text emoter hud at the moment and want to read some quite long strings from a notecard into a list. What is the best way of doing that? Doing it with comma delimited on a single line looks awful for formatting.

 

Jade

Link to comment
Share on other sites

Check http://wiki.secondlife.com/wiki/LlGetNotecardLine#Examples for a working example that may help with your idea - instead of reading one string and treating it as CSV just read line after line; Each one would be a new record you'd be able to put into a list. Also, remember that "if the requested line is longer than 255 bytes the dataserver will return the first 255 bytes of the line."

Edited by panterapolnocy
Link to comment
Share on other sites

6 hours ago, Jade Tachikawa said:

quite long strings

If your strings are very long, and you have more than 100~500 of them, it may be wise to let them sit in the notecards and only read them when you need them.(even tho there's the 1 second delay per line. . ..) Script memory is limited and lists of long strings tend to eat it quickly.

ETA: sorry for the tangent, but in doing some memory tests I noticed that lists with repeated content actually have some sort of basic lossless compression going on:

Quote
list l;

string strRand(integer len)
{
    string ret;
    while(~--len)
    {   ret+=llChar((integer)llFrand(0x5E)+32);
    }
    return ret;
}

default
{
    state_entry()
    {
        integer i;
        integer f = llGetFreeMemory();
        while(f>1000)
        {
            f = llGetFreeMemory();
            ++i;
            //string s = strRand(255); // can only store a bit over 100 of these.
            //string s = "this is a constant string of some length that LSL might do some compression on when multiple consecutive copies are stored into a list, which is kinda cool.";
            string s = llList2String(
            [   "These are alternating strings, used as a test due to the previous result. . .",
                "Which saw that the same string stored over and over again only used 4 bytes per copy."
            ],i&1); // this also leads to efficient storage.
            
            l+=s;
            llOwnerSay((string)llGetListLength(l)+" : "+(string)f+" : \n"+s);
        }
    }
}

*quoted for collapsability.

 

Edited by Quistess Alpha
Link to comment
Share on other sites

13 hours ago, Jade Tachikawa said:

Hi there,

 

I've not done much scripting for ages but I'm working on an text emoter hud at the moment and want to read some quite long strings from a notecard into a list. What is the best way of doing that? Doing it with comma delimited on a single line looks awful for formatting.

 

Jade

a way to do this is by using a line concatenate symbol in the notecard. A plus character for example:
 

This is a long string of up to 255 characters.
+ We want to add this line to the previous read line
+ and this one as well.
Here is the next string
+ with this bit added to it.
This string has no following notecard line concantenated.
Nor does this one.
But this one does
+ because the first character of this notecard line is the concatenate symbol.

Link to comment
Share on other sites

22 hours ago, Mollymews said:

a way to do this is by using a line concatenate symbol in the notecard. A plus character for example:
 

This is a long string of up to 255 characters.
+ We want to add this line to the previous read line
+ and this one as well.
Here is the next string
+ with this bit added to it.
This string has no following notecard line concantenated.
Nor does this one.
But this one does
+ because the first character of this notecard line is the concatenate symbol.

I'd do it by ENDING the line with a character that indicates a continuation follows, because that will cope with both "read the whole nc and eat lots of memory" approaches and "read it when needed" approaches - so that the script knows to stop reading a "line" when it encounters one without the extension character at the end. :)

 

(yes, old unix guy used to escaping newlines with a \ to make my scripts more readable)

  • Like 2
Link to comment
Share on other sites

22 minutes ago, Da5id Weatherwax said:

I'd do it by ENDING the line with a character that indicates a continuation follows, because that will cope with both "read the whole nc and eat lots of memory" approaches and "read it when needed" approaches - so that the script knows to stop reading a "line" when it encounters one without the extension character at the end.

i like, as is more efficient. We don't have to read the next line to find out if it is to be concatenated

  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1025 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...