The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Input Box - cancel button
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

AbbyR

Canada
10 Posts

Posted - 06/01/2016 :  09:55:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

AbbyR

Canada
10 Posts

Posted - 06/01/2016 :  12:53:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

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


Go to Top of Page

Chris D

428 Posts

Posted - 06/01/2016 :  1:11:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

AbbyR

Canada
10 Posts

Posted - 06/01/2016 :  3:53:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


Go to Top of Page

Chris D

428 Posts

Posted - 06/01/2016 :  4:46:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

AbbyR

Canada
10 Posts

Posted - 06/02/2016 :  10:59:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000