Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

"Name not defined within scope" & llGetSubString GLITCH? ... not a newbie question.

Michelle Morphett
Metamorph Maven
Join date: 27 Oct 2006
Posts: 28
03-29-2008 16:18
I've scripted several complicated projects, so even though this LOOKS like a simple forgotten global declaration, it's not, trust me. I'm starting to get the feeling it's some kind of glitch, but would appreciate confirmation & ideas for a workaround.

One object Shouts a single message made up of two UUIDs in a row and a product name at the end ... I checked it, and it is indeed being received correctly through a Listen by the second object on the other side of the sim. The message looks like this: 9bba00a8-5004-8bd9-ad4e-6994e0a364e0e4f0725a-80fd-4f9b-bb6f-fe448e519XXXPavillion

When I pull the UUIDs apart with llGetSubString, the second UUID isn't passing through while the first one is. Even more strangely, the second llGetSubString gets a "Name not defined within scope" error, where the identical first one does not.

At top, I declare ...


string PassID;
string PassOwnersID;


Then lower down I catch the UUIDs with the listen and separate them ...

CODE


listen(integer channel, string name, key id, string message)
{
if(72 == llSubStringIndex(message, "Pavillion")) //this works fine ... it's catching the tail end of the full shouted line. If I put in a Say to read back the entire message here, I get the whole double UUID line recited correctly.
{
PassID = llGetSubString(message, 0, 35); //this works fine. Putting in a Say here reads back the first UUID.
PassOwnersId = llGetSubString(message, 36, 71); //this messes up, even though it's EXACTLY the same as the first UUID llGetSubString call. It gets a "Name not defined within scope" error, where the identical first one does not. Assigning "string" before PassOwnersID makes it read as clean script. But the UUID isn't passing through even then. Putting in a Say here reads back as a blank value.
}
}




Maybe there's a limit on how long the string can be? Thanks much for any help you can give! :)
_____________________

Visit us at Undiscovered (128, 120, 403)
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
03-29-2008 16:26
string PassOwnersID;

...

PassOwnersId = llGetSubString(message, 36, 71);



Is that difference in capitalization in the actual script? (I get this all the time, my pinky doesn't like the shift key)
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
03-29-2008 16:29
From: Viktoria Dovgal
string PassOwnersID;

...

PassOwnersId = llGetSubString(message, 36, 71);



Is that difference in capitalization in the actual script? (I get this all the time, my pinky doesn't like the shift key)

Yes, I was just about to post - that's what it is.
_____________________
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
Michelle Morphett
Metamorph Maven
Join date: 27 Oct 2006
Posts: 28
03-31-2008 08:45
Wow ... next time I log in to SL, people are going to be able to see the giant "L" for "loser" tattooed on my forehead, aren't they? ;)

Thanks much, guys! You found in a few seconds what I couldn't see for three hours. Much obliged.
_____________________

Visit us at Undiscovered (128, 120, 403)
Escort DeFarge
Together
Join date: 18 Nov 2004
Posts: 681
03-31-2008 10:05
When passing parameters as strings it's often a lot easier/more robust to use something like:

string message = llDumpList2String([mykey1, mykey2, myproduct], "|";);

and

list params = llParseString2List(message, ["|"], []);

then you can recover like, e.g.
mykey1 = llList2Key(params, 0);
mykey2 = llList2Key(params, 1);
myproduct = llList2String(params, 2);

NB beware when passing vectors/rotations, recover them like this:
myvector = (vector)llList2String(params, ...);
myrotation = (rotation)llList2String(params, ...);
_____________________
http://slurl.com/secondlife/Together
Yumi Murakami
DoIt!AttachTheEarOfACat!
Join date: 27 Sep 2005
Posts: 6,860
03-31-2008 10:24
From: Michelle Morphett
Wow ... next time I log in to SL, people are going to be able to see the giant "L" for "loser" tattooed on my forehead, aren't they? ;)

Thanks much, guys! You found in a few seconds what I couldn't see for three hours. Much obliged.


No matter how many complicated systems you have created, you are not a programmer until this has happened to you. :) So, welcome. :)
Viktoria Dovgal
Join date: 29 Jul 2007
Posts: 3,593
03-31-2008 12:25
From: Michelle Morphett
Wow ... next time I log in to SL, people are going to be able to see the giant "L" for "loser" tattooed on my forehead, aren't they? ;)

We're sending you one now :D But...
From: Viktoria Dovgal
I get this all the time

... spotting it comes from wasting untold hours making the exact same types of mistakes, again and again.
Michelle Morphett
Metamorph Maven
Join date: 27 Oct 2006
Posts: 28
03-31-2008 12:49
Check this out ...

http://www.michellenephew.com/storage/LoserMichelle.jpg

Props to Incoherendt Randt for sending me the "Toritoys Giant forehead L", which is apparently for sale on SLX for $L5. :)
_____________________

Visit us at Undiscovered (128, 120, 403)
Boss Spectre
Registered User
Join date: 5 Sep 2005
Posts: 229
Script Debugging Tip
03-31-2008 17:20
In most cases the script editor will put the cursor in the column just past whatever it failed on, not just on the line which caused the error, so you can generally look behind the cursor location for the error when you get one.

If you have moved the cursor, you can click on the error message in the lower window to move the cursor back to pointing at the error (or move between them if there is more than one).

~Boss