Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

dataserver event inside listen event if statement

Doc Meredith
Builder-In-Training
Join date: 1 Sep 2007
Posts: 3
01-21-2008 08:35
I have a script that will list all the lines on a notecard and want to use it with a second script which listens for commands ... I have it set up here for a simple radio. I keep getting a syntax error at the dataserver line ... perhaps I've been looking at it too long, but I cannot see the syntax error (LOL).

// Read out a complete notecard from the object's inventory.
string gName = "Radio 49 Stations"; // name of a notecard in the object's inventory
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries
string gURL;
string gStaID;
string gStaName;
string gLastURL;

string getStaID(string sta_info)
{
return llList2String(llParseString2List(sta_info,[","],[]),0);
}
string getStaURL(string sta_info)
{
return llList2String(llParseString2List(sta_info,[","],[]),1);
}
string getStaName(string sta_info)
{
return llList2String(llParseString2List(sta_info,[","],[]),2);
}


default {
state_entry() {
llListen(49, "", NULL_KEY, "";);
//gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventory
gQueryID = llGetNotecardLine(gName, gLine); // request first line
}

listen(integer channel, string name, key id, string message) {
if (message == "off";) {
llSetParcelMusicURL("";);
llSay(0, "Channel 49 Radio OFF";);
}
else if (message == "on";) {
llSetParcelMusicURL(gURL);
llSay(0, "Channel 49 Radio ON";);
}
else if (message == "list";) {
llSay(0,"Channel Listing:";);
dataserver(key query_id, string data) {
if (query_id == gQueryID) {
if (data != EOF) { // not at the end of the notecard
gStaID = getStaID(data);
gURL = getStaURL(data);
gStaName = getStaName(data);
llSay(0, "Channel "+gStaID+": "+gStaName);
++gLine; // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line
}
}
}
}
else if (message == "help";) (continues from here ...... )

Any help appreciated
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
01-21-2008 08:38
You can't put an event inside an event.
_____________________
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
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-21-2008 09:33
once you move your dataserver event out of the listen, when you get list in your listen even call llGetNotecardLine (as you did in your state_entry)... and since you don't seem to be processing anything else but this single notecard in sequential order at the same time, you can omit the query variable, and the check on it in the dataserver event

so it'd be
CODE

//-- in your listen if clause for list
llGetNotecardLine( gName, (gLine = 0) );

//-- NOT inside your listen event
dataserver( key vKeyNull, string vStrData){
if (EOF != vStrData){
//-- get the name/channel and say it
llGetNotecardLine( gName, ++gLine );
}
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -