View Full Version : how to return an array?
Hi you all out there,
I just started with MEL a couple of days ago and I am already kneedeep in it ;-) So here is my question:
How can I make MEL return an array (int or whatever) from a procedure? Just declaring it as "int" in the procedure heading won't work cause then it can't be cast from int[] to int...
example:
$varA = 33;
$varB = 55;
$varC = callup ( $varA, $varB );
print($varC);
proc int callup (int $varAA, int $varBB)
{
$varCC = {$varAA, $varBB};
return $varCC;
}
Please help ;-)
Ingo
|
|
mhovland
10-23-2003, 04:04 PM
If you want to return an int array, just declare your procedure like this:
proc int[] callup (int $varAA, int $varBB)
{
$varCC = {$varAA, $varBB};
return $varCC;
}
If that won't work for you, you will need to explain why in more depth.
MonoPix
10-23-2003, 04:08 PM
proc int[] callup( int $varA, int $varB )
{
int $varC[] = { $varA, $varB} ;
return $varC;
};
$varA = 33;
$varB = 55;
$varC = callup ( $varA, $varB );
print( $varC );
Thanks guys...
I thought so too but it didn't work. I somehow have the feeling that the error message maya produces relates to some other error I have in my script.
But thanks anyway. I guess I have to go for anyother debug round here ;-)
Best regards, Ingo
oh, boy - I now see the problem. Some of my variables got screwed and carried a wrong varibale type along. That of course made the conversion of the type impossible. ;-)
I tried it with "fresh" variables and now it works :-D
(isn't there a way to reset variables. I just know that it's possible to clear arrays, but what is with non-array-variables?
Cheers, Ingo
mhovland
10-23-2003, 06:39 PM
If you are entering your script into the script editor, any variable you declare that isn't enclosed in curly braces { }, is global.
If you are doing quick testing, you should always enclose everything in curly braces, that way all variables fall out of scope after the execution of the code.
thank you - that should help a lot :-)
Cheers
P.S. I am getting along quite well now :-) hehe Everything's working so far
CGTalk Moderation
01-16-2006, 10: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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.