fbpx

How to use the QUESTION command to prompt the operator for information in CNC Professional

The question command can be used in logic to prompt the operator for information or confirmation. The command will display a dialog window centered on the operator screen with a user defined message, a text box for data entry, and an OK and CANCEL button. The question command has three parameters which must be separated by a semi colon.

QUESTION prompt ; var ; [var | text]

prompt
A literal string of text to display in the window as a message or prompt to the operator.  The string should contain all caps.

var
A variable that will be used by the question command to return the data entered by the user in the text box.

[var | text]
An optional variable containing a text that will be used by the question command to be displayed in the text box as default input.  A string literal can also be used instead of a variable.

As an example,  lets suppose we want to create a button on the screen that will prompt the user for his name when clicked.  Select one of the User defined buttons under Design Operator Interface in the CNC SETUP program and assign an mcode to it. Edit the logic in the MCODE.FIL file.


'prompt user for name and display
'hello back to him with his name
1. QUESTION WHAT IS YOUR NAME;\55
2. MESSAGE HELLO \55
-----M25

In the sample, line numbers have been added for reference which should be used when writing logic withing the software.  On line one, the QUESTION command is being used.  The first parameter is literal text string with the prompt we want to display which in this case is  “WHAT IS YOUR NAME”.  This is followed by the required semi colon.  Then variable 55 is being used to capture what the user typed in the text box.  When the user click on the OK button in the window, variable 55 will be set to equal the string of text the user typed in.  On line two, the MESSAGE command is being used to display the word HELLO followed by variable which contains the user name (hopefully).  The message command will take the variable and insert it into the string so that the final output will be “HELLO USER”.