Author |
Topic |
|
AbbyR
Canada
10 Posts |
Posted - 06/01/2016 : 09:55:52 AM
|
OriginPro 9
Hello,
I am using Input box to accept a value from the user and then using that value for further calculations in the program. The issue that I am having is that when I press the cancel button on the input box, it still goes ahead with the rest of the program. All I am looking for is a code to be added which brings the user out of the program when the cancel button is clicked.
Thanks, Abby
|
|
Chris D
428 Posts |
Posted - 06/01/2016 : 12:48:43 PM
|
Hi,
I assume you are using LabTalk and not Origin C. If so here is how you could do it:
int nCancel = 0;
getnumber -c nCancel // -c switch lets you detect if dialog is cancelled.
(Text Edit) sText$
; // End getnumber
if (nCancel)
{
type "Dialog cancelled";
return 0;
}
Thanks, Chris Drozdowski Originlab Technical Support
|
|
|
AbbyR
Canada
10 Posts |
Posted - 06/01/2016 : 12:53:45 PM
|
Hi Chris,
Sorry I should have mentioned that. I am using origin C
quote: Originally posted by Chris D
Hi,
I assume you are using LabTalk and not Origin C. If so here is how you could do it:
int nCancel = 0;
getnumber -c nCancel // -c switch lets you detect if dialog is cancelled.
(Text Edit) sText$
; // End getnumber
if (nCancel)
{
type "Dialog cancelled";
return 0;
}
Thanks, Chris Drozdowski Originlab Technical Support
|
|
|
Chris D
428 Posts |
|
AbbyR
Canada
10 Posts |
Posted - 06/01/2016 : 3:53:48 PM
|
Hi again,
I am attaching the part of the code where I need the cancel button to work. I looked up the links you suggested, but I am not able to implement it. If the user enters 0, the program terminates. I need to add the cancel functionality here.
void OnButtonClick() { double Conc = InputBox(0, "Please enter concentration (mg/mL):"); if(Conc==0) { printf("\n Enter a valid Concentration!"); return; }
Thanks,
quote: Originally posted by Chris D
OK,
Well then if you are using the Origin C GetNBox() function to bring up your dialog, then check the return value. If it is 0 or false, then the dialog was cancelled.
Check out these links for documentation and examples: http://www.originlab.com/doc/OriginC/examples/GetN-Box-Dialog http://www.originlab.com/doc/OriginC/ref/GetNBox
Thanks, Chris Drozdowski Originlab Technical Support
|
|
|
Chris D
428 Posts |
Posted - 06/01/2016 : 4:46:08 PM
|
Hi,
InputBox() will return a missing value (NANUM) if cancelled or user enters a non-numerical value. You can see how to handle this in the doc page for InputBox(): http://www.originlab.com/doc/OriginC/ref/InputBox
Thanks, Chris Drozdowski Originlab Technical Support
|
|
|
AbbyR
Canada
10 Posts |
Posted - 06/02/2016 : 10:59:22 AM
|
Hi Chris,
That worked. I am able to use that functionality now. Another quick question that I have is: I am using a Message Box to display a message saying invalid data when the user inputs 0. Its works fine but when I click OK, I want the program to go back to the input box so that the user can re enter a value. I tried using the goto statement, but it does not work.Is there a better way to control the flow.
Thanks, AbbyR |
|
|
|
Topic |
|
|
|