Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
09-13-2004 16:45
I'm getting an error from this code that says: "Return statement type doesn't match function return type"
Can anyone give me a clue as to what I am doing wrong? I am trying to return an integer between zero and 12.
getRndnum() { float number = llFrand(12); //number between 0 and 12 integer n = llFloor(number); return n; }
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Huns Valen
Don't PM me here.
Join date: 3 May 2003
Posts: 2,749
|
09-13-2004 16:47
The function definition has to agree with the return type. As declared, your function cannot return anything.
integer getRndNum() { // code }
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
09-13-2004 16:55
ok, which would be the correct way?
integer getRndCard() { float number = llFrand(12); //number between 0 and 12 integer n = llFloor(number); return n; }
------or-------
getRndCard(integer n) { float number = llFrand(12); //number between 0 and 12 integer n = llFloor(number); return n; }
?
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
Thanks for the clue!!
09-13-2004 16:59
ok I got it, at least this seems to work...
placing "integer" in front of the function call name worked.
Thanks, I appreciate the clue!
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|
Moleculor Satyr
Fireflies!
Join date: 5 Jan 2004
Posts: 2,650
|
09-13-2004 20:38
Yes, because 'return' returns something, and you have to declare what return will be returning by putting it in front of the function name.
_____________________
</sarcasm>
|
Samhain Broom
Registered User
Join date: 1 Aug 2004
Posts: 298
|
09-14-2004 10:58
this was the first time I used a local variable (local to the function) to do this "return" in the past I would typically use a global variable. I thought I would try to be a little more memory conscious this time so used the return. Thanks for the help. As usual, the Forums ARE all they can be! Thanks man, you help keep this place what it is! (take a rating out of petty cash from me!) haha.
_____________________
rm -rf /bin/ladden #beware of geeks bearing grifts
|