|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
12-26-2007 15:47
Okay, I have grasped more or less how to make a script read from a notecard. What I'm still confused about, though, is those notecards where several data are given in one line separated by pipe characters (|). I need to make a script that reads from such a notecard. How is that done? Thanks!
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
12-26-2007 16:08
Split the line up according to those characters, with either llParseString2List or llParseStringKeepNulls. e.g. the notecard contains name,password name2,password2 You read the card and have a dataserver event based on that. dataserver(key query, string data) { list elements = llParseList2String(data, [","], []); llOwnerSay("Password for " + llList2String(elements, 0) + " is " + llList2String(elements, 1)); }
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Xhawkx Holden
Registered User
Join date: 1 Nov 2006
Posts: 86
|
12-26-2007 16:09
Look up : A.175. llParseString2List
list llParseString2List(string src, list separators, list spacers);
Breaks src into a list, discarding anything in separators, keeping any entry in spacers. The separators and spacers must be lists of strings with a maximum of 8 entries each. So, if you had made the call:
llParseString2List("Parsethisnow! I dare:you to.", ["this", "!", " "], [":"]);
You would get the list:
["Parse", "now", "I", "dare", ":", "you", "to"]
using the pipe as the separator and a blank list for the spacers
|
|
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
|
12-26-2007 16:13
Once you have read the line, you need to parse it using llSubStringIndex. That will give you the index position of the first pipe character. Then use llGetSubString to get the part of the string from the beginning to the index. Next use LlDeleteSubString to delete the initial part of the string and start the process all over with the remaining string. Keep doing this until llSubStringIndex returns a -1 indicating there are no more pipe charecters.
|
|
Dylan Rickenbacker
Animator
Join date: 11 Oct 2006
Posts: 365
|
12-26-2007 16:21
Wooo, that was quick! Thanks a lot, everyone! 
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
12-26-2007 16:29
From: Monica Balut Once you have read the line, you need to parse it using llSubStringIndex. That will give you the index position of the first pipe character. Then use llGetSubString to get the part of the string from the beginning to the index. Next use LlDeleteSubString to delete the initial part of the string and start the process all over with the remaining string. Keep doing this until llSubStringIndex returns a -1 indicating there are no more pipe charecters. Ooh, you don't want to do it like that, believe me - parsing using llSubStringIndex is hellishly slow. Well, for some functions the speed will be okay, but I have suffered using it repeatedly, and it is better to parse the whole thing into a list as soon as possible (even if lists are quite memory-inefficient).
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|
|
Monica Balut
Beam-Me
Join date: 18 Feb 2007
Posts: 311
|
12-26-2007 17:18
After being reminded of the llParse2List solution, I agree it is much better.
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
12-26-2007 17:56
Thank you - I didn't mean to be rude in this instance at all, believe me.
_____________________
http://ordinalmalaprop.com/forum/ - visit Ordinal's Scripting Colloquium for scripting discussion with actual working BBCode!
http://ordinalmalaprop.com/engine/ - An Engine Fit For My Proceeding, my Aethernet Journal
http://www.flickr.com/groups/slgriefbuild/ - Second Life Griefbuild Digest, pictures of horrible ad griefing and land spam, and the naming of names
|