02 August, 2010

MSyntax Flag Definition & Invalid Flag Error

I had some frustrating moments in making flags work for a command using MSyntax. A part of it was my ignorance in reading the function detail, but the other one I am not sure is mentioned in docs. Here is what it says in the doc. for MSyntax::addFlag(const char* shortFlag, const char* longFlag, ......)

shortName  the string representing the short (< 4 character) version of the flag
longName   the string representing the int (> 3 character) version of the flag


=> Short flag name should always be < 4 characters.
=> I defined one flag name like this:  syntax.addFlag("-it", "-infType", MSyntax::kDouble);
and used it with my command like this: myCmd -infType 2 Maya gave me an error, "invalid flag -infType"!

Then I changed the flag long name from -infType to -influenceType it all worked fine. So I wonder there is a problem with defining a long flag name beginning with three lower case characters, followed by an upper case character.

2 comments:

  1. Hey, I think you simply forgot the minus character in your flag definition, try this: syntax.addFlag("-it", "-infType", "Syntax::kDouble);


    Cheers,
    Christopher.

    ReplyDelete
  2. Hi,
    Oh I missed it in the posted code, but I did make sure that '-' was there in the code when I had trouble with it.
    -Maulik

    ReplyDelete