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
 Origin Forum
 How can we test the result of a GetNumber dialog box ?

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
a_user Posted - 08/18/1998 : 1:57:00 PM
How can we know if it's the Ok or Cancel button the user pressed
in a GetNumber dialog box in Origin 4.1 ?
1   L A T E S T    R E P L I E S    (Newest First)
a_user Posted - 08/18/1998 : 1:58:00 PM
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.


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