PDA

View Full Version : Funtion INT return pb


Nicool
09-03-2004, 12:55 PM
Hi!

I want to create a function taht checks if a string is in a given strings array. But I have return problem. It seems I must give a return 0 statement if I want it to work, but if I give a return 0, is return always zero, so I can't check if the string is or not in the array. Urgent

global proc int isStringInArray(string $array[], string $string) {

for($arrayString in $array) {

if($string == $arrayString) {

return 1;
} else {

// return 0; If I do not add else statement, the function can't be loaded into maya
}
}
}

goleafsgo
09-03-2004, 01:31 PM
Why not change it to...

global proc int isStringInArray(string $array[], string $string) {

for($arrayString in $array) {

if($string == $arrayString) {

return 1;
}

}

return 0;
}

...then it will only return 0 if it doesn't find it.

alexx
09-03-2004, 01:33 PM
and yes: the function can not terminate without having a result. 1 or 0..
the function above is the one that works and how it should be

cheers

alexx

Nicool
09-03-2004, 03:35 PM
Thx, don't know why I focused on the puttint false return unto a else statement :banghead:

CGTalk Moderation
01-19-2006, 03:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.