Talk:Notecard Configuration Reader by Maddox Deluxe

From Second Life Wiki
Jump to navigation Jump to search

Suggestions

Hello Maddox

You might find this code easier for validating a key:

<lsl> integer isKey(string test) {

  if ( (key) test)
      return TRUE;
  return FALSE;

} </lsl>

That's all you need to do. There's no need for the detailed inspection you have coded in your isKey() function.

You start your notecard reading by requesting the number of notecard lines - but you never use this information, in fact it appears that you will attempt to process the returned number of lines as if it were line #0 of the notecard itself, and you'll never process the true contents of line 0. In your application, I see no reason to request the number of lines. Just start by requesting a read of line #0.

Your IsElement() function is intended, I think, to ensure that a found texture name occurred at an index that was a multiple of 3. But it doesn't do so at all. Once the code passes the <lsl> if (~index) </lsl> test, it's bound to return TRUE.

Try this:-

<lsl> integer IsElement(list db, string search) {

   integer index = llListFindList(db, [search]);
   if  ( ! (index % 3 ) )

return TRUE; // was found on a stride boundary

   return FALSE; // was not found

} </lsl>

Your code <lsl>

   ++line;
   notecardQueryId = llGetNotecardLine(GetNoteName, line);

</lsl> would be better placed up where you have put the comment: // speed is the key when scripting, ... At present your code will stall on the first error encountered, as it will not go on to read the next notecard line, and will never reach EOF.

Why ask the user to code a full null key where no texture is desired? Why not look for a simpler specific string such as NONE?

I could go on, but that's enough ... except to say: do indent your code properly. You may find the offline tool lslEditor useful for this, as it has an auto-indent feature.

Omei Qunhua 02:05, 22 April 2014 (PDT)


Well Omei, there is many ways to code things and everyone has their own style, but this script works just how it was made to. It has been tested many ways for error checking with the notecard format. I made it from on going project of my, the demo script just shows how you could handle themes UUID keys and using list for them. The "Error Checking" is 100% good.

All you got to do is run the test scripts and you will see they work fine. Try adding some debug output before you say it does not work right. The format notecard was not made to handle spaces, the comment lines works just fine as long you keep each line right under each other.

Maddox Deluxe