Functions to get byte count of a notcard line as well as total bytes used/available.
Lucia Nightfire
Currently, both llGetNotecardLine() and llGetNotecardLineSync() return 1024 bytes of padded data if a multi-byte character is truncated. Due to this, it is impossible to use string length alone to determine if the return was truncated in all scenarios.
This why I was happy to find out that the new llFindNotecardTextSync() function returned byte count for both 'column' and 'length' outputs.
Sadly, despite this benefit, the original intent of those outputs was to be in character count so the function will soon be 'fixed' and the benefit mentioned above will be lost.
This is why I ask for a dedicated, synchronous function to let users know if their saved data will not be able to correctly be read by scripts.
string llGetNotecardLineBytes(string notecard_name);
returns NAK if the notecard is not cached or a count in bytes if it is cached.
Along with getting notecard line bytes, llFindNotecardTextSync(), before it will be fixed, can currently tell a user how many bytes are used/available in a notecard.
This benefit will soon be lost as well when llFindNotecardTextSync() is 'fixed'.
This is why I ask for a dedicated, synchronous function to let users know how much memory is used/available in their notecards.
string llGetNotecardBytesUsed(string notecard_name);
returns NAK if the notecard is not cached or a count in bytes if it is cached.
or
string llGetNotecardBytesAvailable(string notecard_name);
returns NAK if the notecard is not cached or a count in bytes if it is cached.
Thanks for any consideration.
Log In
Bleuhazenfurfle Resident
Would much rather:
integer llGetNotecardSize(string notecard_name);
integer llGetNotecardLineLength(string notecard_name, integer line_number);
string llGetNotecardLineSlice(string notecard_name, integer line_number, integer start, integer end);
The first two both return -1 if not cached (physical things can't have negative size), otherwise the appropriate length in
characters
(reading past the end of the notecard should return 0, not -1, though that may leave a rarely problematic edge case on the last line).Characters being truncated uncleanly, is the only occasion where the number of bytes should be needed, and that is an issue that needs to be fixed separately.
The line slice function should return whole characters up to the usual 1024 bytes past the start offset (with negative indexing), such that this would write out the entire line:
dumpEntireLine(string ncName, integer lineNo) {
integer pos = 0;
integer end = llGetNotecardLineLength(ncName, lineNo);
while ( pos < end ) {
string line = llGetNotecardLineSlice(ncName, lineNo, pos, -1);
llOwnerSay(line); // could also use end in place of the -1 above
pos += llStringLength(line);
}
}
The two line-oriented functions should absolutely be available in sync, the line slice one should be available in both (async as well as sync), while the full notecard size one should probably be async (since it's a one-shot anyhow). The corresponding other two a/sync functions would of course be a bonus, but aren't strictly needed (and llGetNotecardLineSliceSync is
really
getting a tad long!).