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
 Origin Forum
 How can we test the result of a GetNumber dialog box ?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

a_user

USA
0 Posts

Posted - 08/18/1998 :  1:57:00 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
How can we know if it's the Ok or Cancel button the user pressed
in a GetNumber dialog box in Origin 4.1 ?

a_user

USA
0 Posts

Posted - 08/18/1998 :  1:58:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Detecting when a user clicks Cancel in the GETNUMBER (and other) dialog(s).

As you probably discovered, when a user presses the Cancel button in a GETNUMBER dialog box, Origin generates a #Command Error! which will stop your script. If you need to continue processing and want to know which button in the dialog was pressed you can make use of the following general technique.

Use NOTEPAD or another text editor to create a file called UTIL.OGS. Copy the following text to your text editor and save the file.

// Beginning of sample code
[getnumber]
flag=0;
var=%2;
getnumber (%1) var (%3);
flag=1;
return;
// End of sample code

Note that a variable named flag is set to 0 before the getnumber command and set to 1 after the getnumber command. When this code is called via a run.section command, the two lines after the getnumber command will execute only if the user clicks the OK button. Since this code is executing in an external file, the #Command Error! that is generated by pressing Cancel stops the external script from completing, but allows the script that called it to continue. Your calling script can then check the value of the flag variable to determine what action the user took:

•flag = 1 indicates the user clicked OK •flag = 0 indicates the user clicked Cancel

Here is an example of how to call and use the above routine:

sample = 10;
run.section(util,getnumber,"My Variable" sample "Enter your value");
if(flag==1)
{
sample = var;
type -a You clicked OK or pressed Enter and the value of sample is now $(sample);
} else {
type -a You clicked Cancel. Value of sample will not be changed.;
}

This same technique can be applied with other 'GET...' dialogs also.

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