serthy
13th September 2016, 18:46
I'm currently into debugging my code and I'd like to print any object to console.
However I cannot distinguish between an array, a struct or an int/float (if I use .size on an int, a compile error is emmitted):
PrintObject( obj )
{
elem = "undefined";
if( isDefined( array[ i ] ) )
{
if( isPlayer( obj ) )
elem = obj.name;
else if( isString( obj ) )
elem = sprintf( "\"%\"" , obj );
else // could be int/float or an array or a struct
elem = "{object}";
}
printf( "%\n" , elem );
}
Is there any way to get the type?
However I cannot distinguish between an array, a struct or an int/float (if I use .size on an int, a compile error is emmitted):
PrintObject( obj )
{
elem = "undefined";
if( isDefined( array[ i ] ) )
{
if( isPlayer( obj ) )
elem = obj.name;
else if( isString( obj ) )
elem = sprintf( "\"%\"" , obj );
else // could be int/float or an array or a struct
elem = "{object}";
}
printf( "%\n" , elem );
}
Is there any way to get the type?