Go to: Synopsis. Return value. Flags. MEL examples.

Synopsis

stackTrace [-dump] [-parameterCount uint] [-parameterType uint uint] [-parameterValue uint uint] [-state boolean]

stackTrace is undoable, queryable, and NOT editable.

This command controls the MEL stack trace.

Return value

int: in query mode to return state

In query mode, return type is based on queried flag.

Flags

dump, parameterCount, parameterType, parameterValue, state
Long name (short name) Argument types Properties
-state(-s) boolean createquery
Turns displaying the MEL stack trace on or off.
-dump(-d) query
Dumps the current stack of MEL calls.
-parameterCount(-pc) uint create
Returns (as an int) the number of parameters of the function at the given stack level.
-parameterType(-pt) uint uint create
Returns (as a string) the type of the given parameter of the function at the given stack level. Arguments are: stack index, parameter index. Possible return values are: "int", "int[]", "float", "float[]", "vector", "vector[]", "string", "string[]".
-parameterValue(-pv) uint uint create
Returns the value of the given parameter of the function at the given stack level. The type of the return value matches the actual type of the parameter, except for vectors and vector arrays which are returned as float arrays. However, these results can be assigned to vectors/vector arrays and casting will automatically take place (see the MEL example below). Arguments are: stack index, parameter index.

Flag can appear in Create mode of command Flag can appear in Edit mode of command
Flag can appear in Query mode of command Flag can be used more than once in a command.

MEL examples

// Have the stack trace show up on MEL script errors
stackTrace -state on;
// No stack trace for MEL script errors
stackTrace -state off;
// The following is an example of the use of the parameterCount/Type/Value flags.
// A function is defined which uses stackTrace to examine its own inputs.
proc foo( int $inty, int $intya[], float $floaty, float $floatya[], string $stringy, string $stringya[], vector $vectory, vector $vectorya[] )
{
	string $dump[] = `stackTrace -q -d`;
	print( $dump[0] );
	int $count = `stackTrace -pc 0`;
	print( "parameter count: " + $count + "\n" );
	int $i;
	for ( $i=0; $i<$count; $i++ )
	{
		string $type = `stackTrace -pt 0 $i`;
		print( "parameter " + $i + " type: " + $type + "\n" );
		switch ( $type )
		{
		case "int":
			int $val_i = `stackTrace -pv 0 $i`;
			print( "   value: " + $val_i + "\n" );
			break;
		case "float":
			float $val_f = `stackTrace -pv 0 $i`;
			print( "   value: " + $val_f + "\n" );
			break;
		case "string":
			string $val_s = `stackTrace -pv 0 $i`;
			print( "   value: " + $val_s + "\n" );
			break;
		case "vector":
			vector $val_v = `stackTrace -pv 0 $i`;
			print( "   value: <<" + $val_v + ">>\n" );
			break;
		case "int[]":
			int $val_ia[] = `stackTrace -pv 0 $i`;
			print( "   value: [" );
			for ( $j in $val_ia ) print( $j + ", " );
			print( "]\n" );
			break;
		case "float[]":
			float $val_fa[] = `stackTrace -pv 0 $i`;
			print( "   value: [" );
			for ( $f in $val_fa ) print( $f + ", " );
			print( "]\n" );
			break;
		case "string[]":
			string $val_sa[] = `stackTrace -pv 0 $i`;
			print( "   value: [" );
			for ( $s in $val_sa ) print( $s + ", " );
			print( "]\n" );
			break;
		case "vector[]":
			vector $val_va[] = `stackTrace -pv 0 $i`;
			print( "   value: [" );
			for ( $v in $val_va ) print( "<<" + $v + ">>, " );
			print( "]\n" );
			break;
		}
	}
}
// Make some input arrays.
int $i[3] = { 9, 6, 3 };
float $f[4] = { 5.0, 7.0, 9.0, 23.0 };
string $s[2] = { "monkey", "ape" };
vector $v[2] = { <<0.1,0.2,0.3>>, <<7,7,11>> };
// Invoke the function.
foo( 42, $i, 3.14, $f, "oook", $s, <<0,0,1>>, $v );