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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Input Box - cancel button

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
AbbyR 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

6   L A T E S T    R E P L I E S    (Newest First)
AbbyR 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
Chris D 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 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 Posted - 06/01/2016 : 1:11:43 PM
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
AbbyR 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 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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000