The getn command returns "Command error" if the user cliked Cancel button. This command should return the previous (nonchanged) value of the variable but it doesn't. Is there any way to handle the information that user clicked Cancel? Thanks!
Run your script from an OGS file and put the getnumber command in a separate section:
[Main] --other commands-- run.section(,GetValue); if(cancel==1) type "Cancel"; else type "OK"; --more commands--
[GetValue] cancel=1; getn (value) xx (Enter a new value); cancel=0;
Clicking Cancel in the getnumber dialog will return execution to the [Main] section with the variable 'cancel' set equal to 1. The variable 'xx' will retain its previous value.
Thanks Mike, but the method you gave doesn't work realy good because: 1. The once clicked Cancel button doesn't close the dialog box 2. The dialog is closed after the second time Cancel button was clicked and no message is given. Thanks...
Mike is correct and his method works. You should review it carefully to see how it works.
Clicking Cancel or pressing the Esc key normally generates a Command Error - immediately terminating a script. When executed as a run.section() method called from within an OGS file the behavior is changed slightly: instead of terminating, the script returns to the calling section ([Main]) without completing the called section ([GetValue]). The result is that:
Clicking OK or pressing Enter will allow the [GetValue] section to complete (xx will be whatever value the user supplied and cancel will have a value of 0).
Clicking Cancel or pressing Esc will 'short-circuit' the [GetValue] section so that xx will be unchanged and Cancel will now have a value of 1 (because cancel=0; never executed) and your calling section will 'know' that the user cancelled.