GetNumber (or getn) opens a dialog box that allows user input of up to six numbers or strings, which are placed into variables variable1 through variable6. Entries text1 through text6 are the dialog box text associated with each variable. The text dialogboxtitle specifies the dialog box title bar.


getnumber [options] (text1) var1 (text2) var2 ... (text6) variable6 [dialogboxtitle];

For this command, the full name getnumber or the shortened name getn can be used interchangeably.

To specify a string variable in the getn dialog, Origin 8.1 accepts declared string variables (such as string mystring$="Hello";) and string registers. Origin versions 8.0 and prior require that a string register (i.e., %A) be used. Furthermore, in earlier versions, you must use the double % notation, i.e., %%A. This is necessary to protect the integrity of the string variable.

To specify a binary variable with a check box instead of an edit box, insert ":2" after the name of the variable. You can also show or hide items below by specifying ":2s" or ":2h". The former shows all items below if the check box is enabled, while the latter hides them.

A drop down list can also be specified and the variable will represent the selection index in the list. In this case, you must first put the list in a string variable, and specify the character for the string variable after the ":".

Standard lists like the color list can also be specified, and are summarized in this table:

:@C color list
  • C:the 24 basic colors.
  • N: the "None" color (transparent).
  • C: "More colors" && "Custom".
  • R: "Recent colors".

@CNCR means this should have "24 basic colors", "none", "More colors", "Custom" and "Recent colors".

:@D dashed line list
:@T font list
:@S font size list
:@P pattern list
:@B object background list
:@W line thickness size list
:@Z symbol size list


  • In versions prior to 7.0, if a getnumber dialog prompted for a variable that was not defined or missing, the dialog would display the missing value notation : "--". Versions 7.0 and higher display an empty text box for variables that have not been assigned or have missing value.
  • In addition to entering literal text for text1, text2... and dialogboxtitle, you can specify $[OMGfileName].Section.Title. This enables you to access a string title in a message file. The OMGfileName extension is assumed to be OMG. If OMGfileName is not specified, the ORIGIN.OMG file is assumed. For an example using this syntax, see the type command.
  • For the Font Size (@S), Symbol Size (@Z), and Line Thickness (@W) lists, the value returned when a list item is selected within the GetN dialog is the index of the item in the list, not the numeric value of the property.


-c; Prevent Cancel button from aborting script

Syntax: getn -c IsCancel (text1) variable1 [dialogboxtitle]

Open a small dialog box. Set IsCancel to 0 if click the OK button, set to 1 if click the Cancel button. When clicking the Cancel button, no error message like #User Abort! dumps to Script Window and the next script can be executed instead.

-h; Open a help file (.CHM) or a specified page of help file (.CHM) from the GetN dialog


  1. getn -H "path\helpFile.chm" (text1) var1 (text2) var2 ... (text6) variable6 [dialogboxtitle];
  2. getn -H "path\helpFile.chm::pagepath" (text1) var1 (text2) var2 ... (text6) variable6 [dialogboxtitle];
  3. getn -H "path\helpFile.chm::pageID" (text1) var1 (text2) var2 ... (text6) variable6 [dialogboxtitle];

Create a dialog box with a "?" button that can be linked to a help file (helpFile.CHM).

//Click the "?" button to open the page of GetNumber in LabTalk CHM
string fname$ = "C:\myproject.opj";
getn -H "H:\Labtalk.chm::/LabTalk/GetNumber_(command).html" (File Name) fname$:@BBFile [Example1];
//Click the "?" button to open the page of plotxy in X-Function CHM
getn -H "F:\Help\X-Function.chm::37171" (X) nX (Y) nY [Example2];

-pa; Make the current active window as the parent of the GetN dialog

Syntax: getn -PA (text1) var1 (text2) var2 ... (text6) variable6 [dialogboxtitle]

Make the current active window as the parent of the GetN dialog, which forces the user to interact with GetN dialog before he/she can go back to use the parent applications.

-s; Get one numeric value

Syntax: getn -s (text1) variable1 [dialogboxtitle]

Open a small dialog box having a single text box labeled text1. Numbers entered into text1 are stored in variable1. This option is available for entering numeric data only.


Good examples of the GetN command are found in the section of our LabTalk Scripting Guide on Getting Numeric and String Input from Script.

The following example illustrates how you can detect when a user clicks CANCEL in the GetNumber dialog box.

When a user clicks CANCEL 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 box was clicked, you can make use of the following general technique.

Use Notepad or another text editor to create a file called UTIL.OGS. Type the following text in your text editor and save the file.

// Beginning of sample code
flag = 0;
var = %2;
getnumber (%1) var (%3);
flag = 1;
// 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 method, the two lines after the GetNumber command will execute only if the user clicks OK. Since this code is executing in an external file, the #Command Error! that is generated by clicking 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 this routine:

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

This same technique can be applied with other 'GET...' dialog boxes.

Using Origin C's GetNBox from LabTalk

Starting with Origin 8.1 SR1, Origin C's GetNBox is used to replace the older LabTalk GetNumber dialog. To revert back to the older dialog, set the system variable @GN to 0.

Using the Origin C GetNBox allows the number of items to increase from 7 to 50. In addition, more control like adding a branch is now available. The following is a list of new ':@' options:

:@BB<browser> Browse Button
:@F<format> Format numeric value
:@G Branch
:@ZZ Symbol list


// Use :@BB for file and graph browsing
string fname$ = "C:\myproject.opj";
string grname$ = "Graph1";
getn (File Name) fname$:@BBFile (Graph) grname$:@BBGraph (Test @BB);
type fname$;
type grname$;
LTGetN BB Ex1.png

The above example shows how to add browsing for a file and graph name. The :@BB allows you to add browsing for the following:

  • Column / Columns
  • File / Files
  • Graph / Graphs
  • Path
  • Save
  • Sheet / Sheets

Notice some allow browsing for more than one item. These are simply plural. When choosing more than one file, graph, etc. the string returned contains all the items with each item separated by a LF character. Using a string variable you can use the GetToken method and pass LF as the 2nd argument.

// Use :@F for numeric formatting
double myDate = SYSTEM.DATE;
double myPi = pi;
getn (Date) myDate:@FD0 (Pi) myPi:@F*3 (Test @F);
type $(myDate, D9);//use D0 for GetN dialog, but show more details with D9
type $(myPi,*12);
LTGetN F Ex1.png

The following example shows how to create a branch using the new :@G option:

string name$ = "John Doe";
m = 1; d = 1; y = 2009;
getn (Your Name) name$
     (Date of Birth) :@G 
     (Month) m
     (Day) d
     (Year) y
     (-) :@G
     (About You);
LTGetN Branch Ex1.png

Notice that :@G is used to both begin and end a branch. When the label is (-) then the branch is ended. The branch can be set to open or collapsed by appending 1 or 0 to the :@G respectively.

A new Symbol list option (:@ZZ) was added to compliment the Symbol Size list option (:@Z). The new option is used to prompt for a plot symbol.

sym = 1; symSize = 1;
getn (Symbol) sym:@ZZ (Symbol Size) symSize:@Z (Symbol Settings);
LTGetN Symbol Ex1.png

With LabTalk's GetNumber you can hide or show all the items after a check box by placing an optional 'h' or 's' after the '2'. When using the Origin C GetNBox you can now specify the number of items after a check box to be hidden or shown by specifying number after the optional 'h' or 's'. The following example shows you how to show the three items after a check box by placing a '3' after the 's'.

string bp$ = "USA";
dob = 1;
m = 1;
d = 1;
y = 1970;
getn (Enter DOB) dob:2s3 (Month) m (Day) d (Year) y (Birth Place) bp$ 
    (Birth Info);
LTGetN CheckBox Ex1.png

Not Supported:

The following list of options are those that the Origin C GetNBox does not currently support(@GN =1):

:@B object background list
:@D dashed line list
:@T font list
:@P pattern list

If you need to use these or want the old LabTalk GetN behavior for some other reason then simply set @GN=0 at the start of your script and set it back to 1 at the end.