Talk:Notecard Configuration Reader by Maddox Deluxe
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. 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.
This will work.
// Comment 1 [Author Name] = Maddox Deluxe // Comment 2 [Menu Button Name] = Fantasy Tiger // Comment 3 [BackDrop Texture UUID] = 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c // Comment 4 [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000 // Comment 5 [Menu Button Name] = Fantasy Car // Comment 6 [BackDrop Texture UUID] = 517b2288-67ca-b14c-1de2-c5f5fdf5291f // Comment 7 [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000 // Comment 8 [Menu Button Name] = Fantasy Tree // Comment 9 [BackDrop Texture UUID] = f6321118-cc24-6230-78a5-a257a3e33378 // Comment 10 [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
or this will work to.
[Author Name] = Maddox Deluxe [Menu Button Name] = Fantasy Tiger [BackDrop Texture UUID] = 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000 [Menu Button Name] = Fantasy Car [BackDrop Texture UUID] = 517b2288-67ca-b14c-1de2-c5f5fdf5291f [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000 [Menu Button Name] = Fantasy Tree [BackDrop Texture UUID] = f6321118-cc24-6230-78a5-a257a3e33378 [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
this will return error no data found.
[Author Name] = Maddox Deluxe [Menu Button Name] = Fantasy Tiger [BackDrop Texture UUID] = 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000 [Menu Button Name] = Fantasy Car [BackDrop Texture UUID] = 517b2288-67ca-b14c-1de2-c5f5fdf5291f [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000 [Menu Button Name] = Fantasy Tree [BackDrop Texture UUID] = f6321118-cc24-6230-78a5-a257a3e33378 [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
It does not handle spaces over the error checking, I had change the codes, but it did handle spaces at first. I will work the spaces part out and fix it later. I do know I should had not rush and try to share the script so fast, I'm bad at that and should had did more testing before hand. v1.3 not bad, just can't use spaces right now. I been out of second life for a long time, but I'm sure the scripting has change a lot over the months. But the functions still does the job and seem to work very fast. Thanks for showing other ways to check things. From now on I will make sure the script is 100% done before sending it to the wiki.