Talk:LlGetSubString
What should be mentioned is if "start" starts at 0 or at 1.
(Same for llDeleteSubString and llInsertString!)- —The preceding unsigned comment was added on 13:39, 6 March 2007 by Steve Whizenhunt
Start starts at index (integer) 0 -- Eddy (talk|contribs) 11:20, 8 June 2009 (UTC)
- You will find an explanation of indexes in the Specification section and again in the Notes. The text is housed in the Template:LSL_Function/negative index, if you choose to edit it, be sure to make it work for both lists and strings. -- Strife (talk|contribs) 19:01, 8 June 2009 (UTC)
I wonder if anyone can explain this ----> llGetSubString() returns a string. If that string is expressed via another function for example llSay() the result is as you would expect (substring "A" : say "A"). However if the substring is used within the script to make reference to another string or key etc. it fails. The evidence being that if "A" is typed into the script in place of llGetSubString() where substring would return "A" and the "A" in question is the name of a string or key to be used the result is correct. If llGetSubString() is used to gather the "A" up the string or key that is called "A" is not referenced.
I believe this has something to do with UTF-8 or something but I cannot figure out how to get around it. Could a brainbox of lsl contribute on this point? -- Eddy (talk|contribs) 11:20, 8 June 2009 (UTC)
- I doubt it has anything to do with UTF-8. I'm having trouble figuring out what you mean. Say you have a variable named "my_str" that is of type string. Say my_str has the value "ABC". Say we use llGetSubString to get a substring of my_str so that the return is "A". Say we store that result into my_other_str. Are you trying to say that if we change the value of my_str, my_other_str isn't updated? I'm sorry, LSL isn't Lambda Calculus. -- Strife (talk|contribs) 19:01, 8 June 2009 (UTC)
Hi Strife. By UTF-8 I was meaning unicode but I am just starting to learn that aspect of this stuff so may have the wrong end of the stick. I am showing only the elements of the script here because the rest of the idea that I am trying to develop may be worth something. I hope you understand that at some point I need to pay for everything that gets me here.
string A = "12345678-1234-1234-1234-123456789012";
default
{
link_message(integer sender, integer num, string str, key id)
{
llSomeFunction(llGetSubString(str, num, num));
}
}
The substring from str is for example "A". llSomeFunction() uses the key in whatever way. By this method the key fails to be called and is not used by llSomeFunction()
string A = "12345678-1234-1234-1234-123456789012";
default
{
link_message(integer sender, integer num, string str, key id)
{
llSomeFunction(A);
}
}
By writing the "A" directly in to the script the key is called and used by llSomeFunction() and the result is good. I also added a llSay(0, llGetSubString(str, num, num)); and found that the correct substring was being returned. It is the return that seems to be at the heart of the issue. If the return of llGetSubString() is not used (sent through) another function it seems to hold "dead" information. llSomeFunction(A) does work but llSomeFunction(llGetSubString(string, num, num)) doesn't. I think I have worked out how to avoid it by making a double reference to the key required. like string get = llGetSubString() then llSomeFunction(get) to reference string "A". Otherwise another way is to reverse part of the scripting and send the substring via the link message etc. etc. I would love to know why the string gathered by llGetSubString is not enough when typing the same into its place is. -- Eddy (talk|contribs) 01:23, 9 June 2009 (UTC)
I am not sorry that lsl isn't Lambda Calculus cause it's scary. -- Eddy (talk|contribs) 02:53, 9 June 2009 (UTC)
OK. After much messing about I have got the thing working but it is a mess as a result of this problem. however I now understand (although not why) that string A = "blahblahblah"; cannot be referenced by a string "A" since string A is a label and not a string. So I have to ask if(str == "A") { do the thing with string A }. My brilliant idea is fast becoming a mess of lag and nonsense. While trying to solve this (and I may not give up yet) I tried making a function to cut out a lot of mess but kept being told that there was a failed UThread injection and to try again later. I wonder if you might explain a little please Strife? -- Eddy (talk|contribs) 09:06, 9 June 2009 (UTC)
Ohhh at runtime you are trying to access a variable by it's name. You can't do that. You see to do that, LSL would need dynamic binding... which it doesn't have. Which would be just a short hop away from dynamic variables. LSL is a strongly typed language with all of the binding done at compile time. Supporting this would be a HUGE overhaul to the language and make it run slower (trust me on this). Sorry. -- Strife (talk|contribs) 12:56, 10 June 2009 (UTC)
Thanx as usual Strife for your great effort. btw good to see you back (hope the computer is holding up(would be nice to see you in world some day)). I went to using a strided list affair to access the keys. The object I'm making is becoming a gem. I really wish you were in world so you could see. Thanx for explaining (may I call you freind?) Strife. -- Eddy (talk|contribs) 13:00, 10 June 2009 (UTC)