Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Return problems

Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
02-25-2006 16:02
Before I go completely off my head, could somebody explain why the following user-defined function:-
CODE

switch(integer raining)
{
if (raining==1)
{
raining=0;
llShout(7,"off");
}
else
{
raining=1;
llShout(7,"on");
}
return (raining);
}


gives rise to a 'Return statement type doesn't match function return type' error?
_____________________
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-25-2006 17:28
You defined a function that takes an integer as input and returns nothing to the calling function.

Then you tried to return an integer.

You either need to do this:

CODE

integer switch (integer raining)
{
//...same body...
return raining;
}


Or (as seems more likely) you want to make raining a global.

CODE

integer raining;

switch()
{
//...same body...
//return; // not actually needed
}
Selador Cellardoor
Registered User
Join date: 16 Nov 2003
Posts: 3,082
02-26-2006 05:48
Argent,

Many thanks. :)
_____________________