Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

simple listen error

Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-15-2007 14:46
it probuly is a simple problem im having

CODE

listen(integer channel, string name, key id, string message)
{
if((message = "start") & (started = FALSE))
{
llMessageLinked(LINK_SET, 0, "start", NULL_KEY);
started = TRUE;
}
else if((message = "stop") & (started = TRUE))
{
llMessageLinked(LINK_SET, 0, "stop", NULL_KEY);
started = FALSE;
}
}


get a error at the if((message = "[command]";) & (started = [] )error) get it on both
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-15-2007 15:04
From: Mrc Homewood
it probuly is a simple problem im having

CODE

listen(integer channel, string name, key id, string message)
{
if((message = "start") & (started = FALSE))
{
llMessageLinked(LINK_SET, 0, "start", NULL_KEY);
started = TRUE;
}
else if((message = "stop") & (started = TRUE))
{
llMessageLinked(LINK_SET, 0, "stop", NULL_KEY);
started = FALSE;
}
}


get a error at the if((message = "[command]";) & (started = [] )error) get it on both


x = y is an assignment. If you want to do a comparison, use x == y. e.g.

if((message == "start";) & (started == FALSE))

Also, & is a bitwise operator - used with bitmasks and the like. You probably want &&, which a boolean operator (uses true and false).
_____________________
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
11-15-2007 15:06
figured it was the problem, do that stupid mistake all the time
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
11-16-2007 03:28
yeah, with me it's either that, or I wind up putting a semi colon on the end of the if statement... lol
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-16-2007 05:31
From: Johan Laurasia
yeah, with me it's either that, or I wind up putting a semi colon on the end of the if statement... lol


Yeah, I've been a professional software engineer for 10 years, and that one still caught me the other day!
_____________________