Q:  How can I use argv and argc?

A:  We do not recommend making your application rely on command line arguments because they are not available when the program is launched by the Workspace Manager.  Use the Defaults mechanism instead, and provide an Options or Preferences panel by which your users change the default values.  See NXRegisterDefaults() and NXGetDefaultValue().

Currently  the Application object sets various parameters based on command line argument pairs of the form  "- <flag> <value>"  (such as  -NXHost MyHost  or  -NXShowPS YES ) and then removes those arguments from argv and argc.  Your program should not depend on argv and argc, instead use the variables NXArgv and NXArgc that can be used anywhere within your program after the first message is sent, that is, after the initialize methods have completed.  These variables will contain the arguments remaining after the Defaults-type arguments have been removed. NXArgv[0] will be the full pathname of a Workspace Manager-launched application.  Note: if the program was launched from a shell then NXArgv[0] will contain the path specified in the command.  In order to write a very robust application, one should check whether the value begins at "/".

You will need to import <defaults/defaults.h> (or <appkit/defaults.h for pre-3.0) to get the declarations of the variables NXDefaultsVector, NXArgv, and NXArgc.



QA3

Valid for 1.0, 2.0, 3.0