DeadlyNightshade
11-11-2012, 01:20 PM
Ok this is confusing.
So MEL doesn't really have a boolean variable type - but you can create booleans by just ignoring the variable type in the declaration, like this:
$variable = false;
This got me thinking about procedures that returns booleans. How exactly are they written?
If I want a procedure to return a float for me, I have to write the procedure like this:
global proc float[] procedure()
{
global float $returnVal[];
// Some code
return $returnVal;
}
So how exactly do you return a boolean when it's not even a valid variable type?
Coz this just does not work:
proc procedure()
{
global $bool = false;
// Some code
return $bool;
}
...because Maya complains that the procedure does not have a return value.
I want to create some procedures that does some selection queries - and if my selections are "valid", these procedures will return a boolean with a value of "true". My other procedures will then only "work" if this returned boolean is true (ie: If the selection is faulty, the procedure won't fully execute).
The reason for this is just to keep down the amount of code. I don't want to have a ton of lines with code everytime I need to query the selection in my procedures. It's more "neat" if I can just call on another procedure (a selection query procedure) that then returns a bool for me, telling me if the selection is valid or not.
So MEL doesn't really have a boolean variable type - but you can create booleans by just ignoring the variable type in the declaration, like this:
$variable = false;
This got me thinking about procedures that returns booleans. How exactly are they written?
If I want a procedure to return a float for me, I have to write the procedure like this:
global proc float[] procedure()
{
global float $returnVal[];
// Some code
return $returnVal;
}
So how exactly do you return a boolean when it's not even a valid variable type?
Coz this just does not work:
proc procedure()
{
global $bool = false;
// Some code
return $bool;
}
...because Maya complains that the procedure does not have a return value.
I want to create some procedures that does some selection queries - and if my selections are "valid", these procedures will return a boolean with a value of "true". My other procedures will then only "work" if this returned boolean is true (ie: If the selection is faulty, the procedure won't fully execute).
The reason for this is just to keep down the amount of code. I don't want to have a ton of lines with code everytime I need to query the selection in my procedures. It's more "neat" if I can just call on another procedure (a selection query procedure) that then returns a bool for me, telling me if the selection is valid or not.
