Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

dataserver?? Can't read a notecard...

WindyWeather Vanalten
Registered User
Join date: 27 Nov 2006
Posts: 53
12-08-2006 13:58
I'm experimenting with dataserver and sending email. This script finds the dropped notecard, and apparently gets a read event, but can't read anything from the card. Card is plain text with no included inventory items.

Gee... Even tried a timer to allow note card to actually arrive in inventory. That didn't help. Can anybody see what's wrong? I've added about all the debug statements that I can think of here.

It sends an email. <<email address changed to protect the guilty.>> But email is empty and reported message length is zero. EOF is apparently the first message sent.

Thanks,
wwv

CODE

string notecardId;
integer working = 0;
key gQueryID;
integer gCurrentLine = 0;
string messageString;


default
{
state_entry()
{
// allow anybody to give us stuff, so we can get the
// notecards from anybody.
llAllowInventoryDrop(TRUE);
}

touch_start(integer total_number)
{
llSay(0, "Create a notecard in your inventory, fill it out and then drop it on the ball to send the comment or suggestion to my Master. And Thank you." );

}

changed(integer change)
{
llSay(0, "Changed event "+(string)change );
if ((change & CHANGED_INVENTORY) && (working == 0))
{
notecardId = llGetInventoryName(INVENTORY_NOTECARD,0);
if ( notecardId == "" )
{ llSay(0, "Error - message not found" );
return;
}
working = 1;
llSay(0,"Your message has been received. One moment while we send it.\n"+notecardId);
gCurrentLine=0;
messageString = "";
//gQueryID = llGetNotecardLine(notecardId, gCurrentLine);
llSetTimerEvent( 5. );
}
else
{
llSay(0, "Change is not CHANGED_INVENTORY "+(string)change + "or we are working "+(string)working );
}
}

timer()
{
if ( working )
{
gQueryID = llGetNotecardLine(notecardId, gCurrentLine);
}
llSetTimerEvent(0.);
}

dataserver (key query_id, string data)
{
llSay(0, "dataserver "+(string)query_id+" "+data);
// Make sure this is the line we requested.
if (query_id != gQueryID)
{
llSay(0,"dataserver queryId don't match - got: "+(string)query_id + " wanted: " + (string)gQueryID );
return;
}

if (data != EOF)
{
llSay(0,"Message Line: " + data);
messageString = messageString + data;
++gCurrentLine; // increase line count
gQueryID = llGetNotecardLine(notecardId, gCurrentLine); // request next line
}
else
{
llSay(0,"Sending your message now."+(string)llStringLength(messageString));
llEmail("bogus@nowhere.net", "Comment or Suggestion",
messageString );
llSay(0, "Your message has been sent. Thank you." );
llRemoveInventory( notecardId );
working = 0;
}
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-08-2006 14:38
Well your code looks ok.
I modified it very slightly to thsi and it works jsut fine

CODE

string emailaddy = "bogus@bogus.net";

string notecardId;
key gQueryID;
integer gCurrentLine = 0;
string messageString;


default
{
state_entry()
{
// allow anybody to give us stuff, so we can get the
// notecards from anybody.
llAllowInventoryDrop(TRUE);
}

touch_start(integer total_number)
{
llSay(0, "Create a notecard in your inventory, fill it out and then drop it on the ball to send the comment or suggestion to my Master. And Thank you." );
}

changed(integer change)
{
llSay(0, "Changed event "+(string)change );
if ((change & CHANGED_INVENTORY) )
{
notecardId = llGetInventoryName(INVENTORY_NOTECARD,0);
if(notecardId != "") state working;
}
}
}

state working
{
state_entry()
{
llSay(0,"Your message has been received. One moment while we send it.\n"+notecardId);
gCurrentLine=0;
messageString = "";
gQueryID = llGetNotecardLine(notecardId, gCurrentLine);
llSetTimerEvent( 10 );
}

timer()
{
llSay(0,"Error reading notecard?");
}

dataserver (key query_id, string data)
{
//llSay(0, "dataserver "+(string)query_id+" "+data);
// Make sure this is the line we requested.
if (query_id != gQueryID)
{
llSay(0,"dataserver queryId don't match - got: "+(string)query_id + " wanted: " + (string)gQueryID );
return;
}

if (data != EOF)
{
// llSay(0,"Message Line: " + data);
messageString = messageString + data;
++gCurrentLine;
gQueryID = llGetNotecardLine(notecardId, gCurrentLine);
}
else
{
llSay(0,"Sending your message now."+(string)llStringLength(messageString));
llEmail(emailaddy, "Comment or Suggestion", messageString );
llSay(0, "Your message has been sent. Thank you." );
llRemoveInventory( notecardId );
state default;
}
}
}
WindyWeather Vanalten
Registered User
Join date: 27 Nov 2006
Posts: 53
Thanks, but no cigar...
12-08-2006 16:33
Newgate,

That was very helpful regarding how to use state xxx calls.
And it does send a message, just like before, with no content.
After reading the notecard it llSays a message with the number of bytes read and they still are zero and the email message is empty except for the header location info.

Still no joy for content of the notecard.

Thanks,
wwv
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
12-08-2006 18:57
How long are the lines in your notecard?
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
WindyWeather Vanalten
Registered User
Join date: 27 Nov 2006
Posts: 53
Lines are not that long...
12-08-2006 22:46
From: Strife Onizuka
How long are the lines in your notecard?

Nothing out of the ordinary. I tried a couple of different cards. One was a copy of the script and another was a product description of a Japanese fan. Certainly not 65K...

BTW, I just tested the example with the llGetNoteCardLine Wiki page. It fails the same way. Minimal changes to the example - straight cut and paste, except mod to "touch to trigger" rather than launch in state_entry. It doesn't work... Is this a bug?

There must be a notecard, or the script fails with an error. And if you change the notecard inventory index, it reports the error. The dataserver is triggered. But it fails to read any data.
Here is the script after some minimal diagnostics are added.

wwv

CODE

// Read out a complete notecard from the object's inventory.
string gName; // name of a notecard in the object's inventory
integer gLine = 0; // current line number
key gQueryID; // id used to identify dataserver queries
integer working = FALSE;

default
{
state_entry()
{
llSetText("Test Comment Ball", <.7,.7,1.>, 1.);
}

touch_start(integer total_number)
{
if ( working ) return;
llSay(0,"Touched");
gLine = 0;
gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventory
gQueryID = llGetNotecardLine(gName, gLine); // request first line
if ( gName == "" || gQueryID == NULL_KEY )
{ llSay(0, "Error reading notecard: "+gName+":"+(string)gQueryID);
}
else
{
llSay(0,"Dataserver triggered" );
working = TRUE;
}
}

dataserver(key query_id, string data)
{
llSay(0,"Dataserver entry "+(string)query_id+":"+(string)gQueryID+":"+data);
if (query_id == gQueryID)
{
if (data != EOF)
{ // not at the end of the notecard
llSay(0, (string)gLine+": "+data); // output the line
++gLine; // increase line count
gQueryID = llGetNotecardLine(gName, gLine); // request next line
}
else
{ working = FALSE;
}
}
}
}
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-09-2006 01:36
From: WindyWeather Vanalten
Newgate,

That was very helpful regarding how to use state xxx calls.
And it does send a message, just like before, with no content.
After reading the notecard it llSays a message with the number of bytes read and they still are zero and the email message is empty except for the header location info.

Still no joy for content of the notecard.

Thanks,
wwv



Thats very weird Windy, I tested it before I posted, very unusual for me!, and it worked ok.

Does it print anthing? (I see you havea print line statement)
I tried it with a simple notecard I had in inventory and it was sent as expected.


oh and 65K??? you are limited to 16K of script memory so anything over that will kill your script.
Strife Onizuka
Moonchild
Join date: 3 Mar 2004
Posts: 5,887
12-09-2006 05:54
I didn't ask how many lines or how long the notecard was, I asked how long the lines were.
Notecard lines are limited to 255 charachters per line.
_____________________
Truth is a river that is always splitting up into arms that reunite. Islanded between the arms, the inhabitants argue for a lifetime as to which is the main river.
- Cyril Connolly

Without the political will to find common ground, the continual friction of tactic and counter tactic, only creates suspicion and hatred and vengeance, and perpetuates the cycle of violence.
- James Nachtwey
WindyWeather Vanalten
Registered User
Join date: 27 Nov 2006
Posts: 53
The last test...
12-09-2006 08:57
Yes, I understood...
The last test had one line that was less than 40 characters. No tests exceeded that limit.

wwv
WindyWeather Vanalten
Registered User
Join date: 27 Nov 2006
Posts: 53
Problem Solved...
12-09-2006 15:35
Newgate and I got together and passed objects back and forth and found the problem.

Turns out that there are three kinds of notecards... Let's call them..
(1) Virgin notecard has never had an embedded object in it.
(2) Embedded notecard has an embedded item, or more than one.
(3) Naughty notecard has had embedded item in the past, but not one now.

You can only send Virgin notecards to dataservers. And there appears no way to convert a naughty notecard into a virgin.

The script is just fine. Always was.

Sigh... Another bug to report.

wwv
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-09-2006 16:11
From: WindyWeather Vanalten
Newgate and I got together and passed objects back and forth and found the problem.

Turns out that there are three kinds of notecards... Let's call them..
(1) Virgin notecard has never had an embedded object in it.
(2) Embedded notecard has an embedded item, or more than one.
(3) Naughty notecard has had embedded item in the past, but not one now.

You can only send Virgin notecards to dataservers. And there appears no way to convert a naughty notecard into a virgin.

The script is just fine. Always was.

Sigh... Another bug to report.

wwv



To elaborate sligthtly, A notecard that has ever had an embeded link seems to retain the embedded property and hence returns EOF on all Dataserver requests.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-13-2006 03:18
Looks like there may have been another cause of this fault. Check this related thread dataserver appears to be broken