THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 24/11/2009 at 12:41, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 11.027
Platform:
Language(s) : C++ ;
---------
Hi Everyone,
I have a plugin that parses the command line for an option and an argument to that option. Here's an example of the correct usage for the option:
CINEMA_4D -match "*_hand_*" myscene.c4d
If the user omitted the option argument ("*_hand_*" in the example), I'd like to print an error message and exit cinema4d without loading any additional plugins and without crashing.
Is there a way to do this? Here's the current code snippet from PluginMessage, case C4DPL_COMMANDLINEARGS:
std::string matcher = "";
std::string c4dFile = "";
for (LONG i = 0; i < args->argc; i++)
{
if (!args->argv) continue;
if ( !strcmp(args->argv,"-match") )
{
args->argv = NULL;
if ( (i+1) < args->argc && args->argv[i+1] )
{
const char* mstr = args->argv[i+1];
if (strcmp(mstr, "-"))
{
matcher = mstr;
args->argv[i+1] = NULL;
std::cerr << std::endl << "Will try to match textures with: " << matcher << std::endl;
}
}
if (matcher.empty())
{
std::cerr << "ERROR: Must specify a match string if using the -match option." << std::endl;
// HERE IS WHERE I WANT TO TELL C4D TO EXIT. throw is not graceful!
throw (-1);
}
}
Any ideas? Thanks!
P.S., how do you enter code snippets in this fancy new RichText Editor?