The optional kwl argument specifies a list of keywords that will be recognized by the next user-input (acedGetxxx()) function call. The keyword value that the user enters can be retrieved by a subsequent call to acedGetInput(). (The keyword value will be available if the user-input function was acedGetKword().) The meanings of the keywords and the action to perform for each is the responsibility of the ObjectARX application.
The acedGetInput() function always returns the keyword as it appears in the kwl argument, with the same capitalization (but not with the optional characters, if those are specified after a comma). Regardless of how the user enters a keyword, the application has to do only one string comparison to identify it, as demonstrated in the following example. The code segment that follows shows a call to acedGetReal() preceded by a call to acedInitGet() that specifies two keywords. The application checks for these keywords and sets the input value accordingly.
int stat; ads_real x, pi = 3.14159265; char kw[20]; // Null input is not allowed. acedInitGet(RSG_NONULL, "Pi Two-pi"); if ((stat = acedGetReal("Pi/Two-pi/<number>: ", &x)) < 0) { if (stat == RTKWORD && acedGetInput(kw) == RTNORM) { if (strcmp(kw, "Pi") == 0) { x = pi; stat = RTNORM; } else if (strcmp(kw, "Two-pi") == 0) { x = pi * 2; stat = RTNORM; } } } if (stat != RTNORM) acutPrintf("Error on acedGetReal() input.\n"); else acutPrintf("You entered %f\n", x);
The call to acedInitGet() prevents null input and specifies two keywords: “Pi” and “Two-pi”. When acedGetReal() is called, the user responds to the prompt Pi/Two-pi/<number> by entering either a real value (stored in the local variable x) or one of the keywords. If the user enters a keyword, acedGetReal() returns RTKWORD. The application retrieves the keyword by calling acedGetInput() (note that it checks the error status of this function), and then sets the value of x to pi or 2pi, depending on which keyword was entered. In this example, the user can enter either p to select pi or t to select 2pi.