Jump to content

llParseString2List


CaseyKox
 Share

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

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

Recommended Posts

 

 OK I'm using llList2ListStrided to build a menu, Also using a note card to read from and I'm needing tips on how to add simple key to ignore  an area in my list for when the spacer is not added in the note card for that part of the list.

IE

Command|1|1 would be with the command

Command|1 (come out looking like Command|1|NULL in the string upon after reading is done by the data server end) would be with out the command and needed a way to add a ignore key so I don't have to run a second list search on building the menu

Link to comment
Share on other sites

is not clear to me what list data format is after being read in, or what you mean by spacer

if you could give more info on what the format is then might be able to help

Command|1|1 and Command|1|NULL isn't really enough info to suggest possible alternate solutions

Link to comment
Share on other sites

sorry was speed typing.

list Name = ["Item Name|Command 1|command 2","Item Name|Command 1|X"];

so when the note card is read from like

toke = Item Name|Command 1|command 2

toke = Item Name|Command 1

where you see "Item Name|Command 1' I would need to add "|X" so my script would knows to skip the 3rd command when reads the part of the list. sorta like key oh nothing is there and we don't need to worry about the 3rd element. 

Link to comment
Share on other sites

So if I'm understanding you correctly, you're saying you do something like this?

  1. Read a notecard line into a string.
  2. Split the string into a temp list with something like  list temp = llParseString2List(notecardline,["|"],[]);
  3. Add this temp list to a combined list. You called it "Name" in your above post.
  4. Repeat steps 1-3 until you've read all the notecard lines you need.
  5. Attempt to treat the combined "Name" list as a strided list to build a menu.

But you hit problems because the strides are not consistent. Is that correct?

If so, you can inject a dummy element into your list in step #2 by checking the length with llGetListLength. A typical input like "Item Name|Command 1|command 2" would have a length of 3. Whereas the alternate case of "Item Name|Command 1" would have a length of 2. If the temp list in step #2 has a length of 2, simply add an extra list element to it before appending the whole thing to your combined "Name" list. That will enforce the three stride structure you appear to be going for.

list temp = llParseString2List(notecardline,["|"],[]);
if(llGetListLength(temp) == 2)
{
	temp += ["X"];
}

Naturally, you'll need to also update the part of your code that builds the menu and have it check if the element it's looking at matches your dummy flag and not add it to the final menu.

Edit: And this is just assuming you only ever have either one or two command elements in your notecard line. Is that a given? Is it possible you might see a notecard line with no commands, or more than two?

Edited by Fenix Eldritch
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1361 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...