MString/ unable to read memor


#1

Hello fellows,

I recently wanted to get onto the C++ side again making a little plugin working my way up.

So far it is rather blank and just prints out a message. Next step was trying to get a value via executeCommand from a global variable called $Source created by my mel-script.

MStatus MyCommand::doIt(const MArgList &argList)
{
	MStatus status;
	MGlobal::displayInfo("MyCommand did it");

	MString result;
	MString cmdStr = "proc string getSource() { global string $Source; return $Source;};";
	MGlobal::executeCommand(cmdStr, result);

	if (status != MS::kSuccess)
		{
		return status;
		}
}

As far as I have read, this error comes up if a variable is not initialized. But if I understood it correctly, MString should be initialized on creation…
Looking into other examples there is no difference in the declaration.

So, where did I go wrong?


#2

No idea, but maybe it has something to do with the fact that you command does not return anything? You only define a procedure, but you do not call it.


#3

Oh my god, this is embarrassing. That`s where I was wrong.

Thank you for taking your time.


#4

Hey, I was right! That’s a good monday :slight_smile: