is there a way to check that a .mel file has been sourced? Something that could be prevented if the file does not exist or there is a syntax error.
My thought had been to call a function from the file in a catch statement. If the file wasn't loaded, it comes up with Cannot find procedure "BBload". But it doesn't throw an error with the catch statement can catch. Any other suggestions?
Figured something out. I was trying to generate an error when accessing an unknown function. That way I can catch it and determine that the mel file has not been sourced.
Although the calling the function in mel doesn't generate a trappable error, it does work if you call the function from a plugin.
MGlobal::executeCommand("testSourcingCmd()")
This will return MS::kSuccess when the testSourcingCmd is available (i.e. file is correctly sourced) and MS::kFailure when the function is unavailable due to incorrect sourcing. Can't think of a way to do it inside a mel script though.
that's exactly what I was trying to write. I realize now that I just had the incorrect syntax. The code that I wrote in the last post does exactly the same as your code, only in a C++ plugin.
The mel file in question already has an empty function that I just use to test wether it's available. Spot on though.