2.2.21 newbook


Brief Information

Create a new workbook or matrix book

Command Line Usage

1. newbook name:="ASCII Data";

2. newbook sheet:=0;

3. newbook name:="Experiment1" sheet:=4 hidden:=1;

4. newbook name:="curves" result:=bn$ option:=lsname;

5. newbook mat:=1;

X-Function Execution Options

Please refer to the page for additional option switches when accessing the x-function from script

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Desired Book Name name

Input

string

""

Specifies the desired name for the workbook. This name can be set to long name only or both long name and short name, depends on the option variable.

Number of Sheets sheet

Input

int

-1

Specifies the number of sheets in the workbook. -1 means number of sheets in the template will be used.

Template template

Input

string

"Origin"

Specifies the template to use.

Actual Book Name result

Output

string

bkname

Specifies the string to store the short name of the created workbook.

Create as Hidden hidden

Input

int

0

Specifies whether or not the new workbook should be hidden after it is created (see String Register, %@N).

Name Option option

Input

int

lname

Specifies how to set the long name and short name of the workbook with the name variable.
Option list

  • lname:Long name only
    Sets only the long name of the workbook to the desired book name.
  • lsname:Long and Short name
    Sets both long name and short name of the workbook to the desired book name.
  • enumln:Enumerate Long Name to short name index
    Sets long name of the workbook to the desired book name, and enumerates it to the same as short name index.
New Matrix Book mat

Input

int

0

Option of matrix book or workbook.

Keep Sheet Name keep

Input

int

0

Specifies whether or not keep the sheet name in template. If no, default enumeration will be used.

Do not Create if Found chkname

Input

int

1

Check the name; do not create this newbook if it already exists. Setting chkname:=0 will create newbook and enumerate (i.e. newbook1, newbook2, etc.).

Description

The newbook function creates a new workbook or matrix book. You can specify the number of sheets in the book, the book name and whether the workbook should be hidden. Note: If you have set the option variable to Long and Short name and specified a book name that coincides with the short name of an existing book, this X-Function will not create a new book, because two books cannot have the same short name.

Examples

// newbook is used when you need to create a new Workbook.
// Begin with a new, empty folder
pe_mkdir Example;
pe_cd Example;
// Repeat three times
loop(ii,1,3)
{
	// We only want one 'Results' workbook
	if( !exist(Results) )
	{
		// Based on ORIGIN.OTW
		newbook name:=Results template:=origin sheet:=2 option:=1;
		// We name the Sheets
		layer1.name$ = QC;
		layer2.name$ = Standard;
	}
	// These names will enumerate
	newbook name:=Run option:=0 result:=bkname$ template:=bin chkname:=0;
}
win -s T;  //Tile the windows horizontally

Related X-Functions

newsheet