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
 InputBox cancel
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

AG_Kraemer

Germany
5 Posts

Posted - 06/20/2003 :  10:38:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Edit: I meant the InputBox, not the progressbox

Hello,

I am a bit unhappy that the programm stops immediately once the cancel button in a progressbox is pressed. I would like to clean up a few thing which have been generated by the function up to this point. So, how do I intercept this? It appears there is no integer result returned by the progressbox procedure (e.g. messagebox--> IDNO=7). So how do I do this?

Toralf

Edited by - AG_Kraemer on 06/20/2003 10:48:28 AM

Edited by - AG_Kraemer on 06/20/2003 11:01:09 AM

easwar

USA
1965 Posts

Posted - 06/20/2003 :  10:53:53 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Toralf,

You could do something like in the code pasted below...

Easwar
OriginLab.



void pbTest()
{

progressBox pBox("Computing...hit Esc to stop.");
pBox.SetRange(0,100);
pBox.Set(0);

// Loop over steps - performing your computation
for(int ii = 0; ii <= 100; ii++)
{
// just wait a while on each step
LT_execute("sec -p 0.1");

// Check if user hit Cancel key by updating progress box
if(!pBox.Set(ii))
{
printf("Computation terminated at step %d!\n", ii);
break;
}
}
}


Go to Top of Page

AG_Kraemer

Germany
5 Posts

Posted - 06/20/2003 :  10:59:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for your response! But I asked the wrong question: Not the cancel button of the progressbox was my problem but the the Cancel Button in the InputBox:

repeatstr = InputBox("How many repetitions...)

Regards,
Toralf
Go to Top of Page

easwar

USA
1965 Posts

Posted - 06/20/2003 :  12:02:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Toralf,

You are correct - Clicking the Cancel button from the InputBox dialog results in run-time error and in termination of program - there is currently no way to catch this.

We have added try-catch in Origin C our internal version and this will be available in the next release version.

For now, you could use LabTalk from within OC and use the LabTalk GetString command, as in the code example posted below:

Easwar
OriginLab.


void test()
{
string strCMD = "flag = 0; getstring (Enter string:); flag = 1;";
LT_execute(strCMD);

string strInput;
double dFlag;
LT_get_var("flag", &dFlag);
if(dFlag)
{
char szTemp[100];
LT_get_str("%B", szTemp, 100);
strInput = szTemp;
printf("You entered: %s\n", strInput);
}
else
{
printf("You hit the Cancel button!\n");
}
}



Edited by - easwar on 06/20/2003 12:19:13 PM

Edited by - easwar on 06/20/2003 12:20:30 PM
Go to Top of Page

AG_Kraemer

Germany
5 Posts

Posted - 06/23/2003 :  03:01:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi easwar,

Thanks again for your quick reply! I have thought about the Labtalk detour. But as I try to keep the C-file as Labtalk free as possible I was hoping I have just overlooked the proper use of the inputbox - thanks for enlightening me!

Regards,
Toralf
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