2.14.2.22 pe_path

Brief Information

Get current Project Explorer path or path of specified window

Command Line Usage

1. string strPath$; pe_path page:=Book1 path:=strPath$ type:=0; // Puts Project Explorer path to Book1 into strPath$ string variable.

2. pe_path page:=myFolder type:=folder active:=1; // Changes active folder in Project Explorer to the subfolder "myFolder" if it exists.

Variables

Display
Name
Variable
Name
I/O
and
Type
Default
Value
Description
Name of page or folder page

Input

string

Either the name of the window (workbook, graph, etc) or the subfolder relevant to the desired functionality. See the path and type variable for functionality information.
Path path

Input/Output

string

<optional>
If type is window, this variable outputs the path of the specified window. If type is folder, this variable can be both input and output. As input, if active variable is 1, it specifies the subfolder in the current folder to activate.
Target Type type

Input

int

0
Specify the type of the target: window or subfolder. See path variable for more information.

Option list:

  • window:Page Short Name
    Search for a window.
  • folder:Subfolder Name
    Search for a subfolder.
Activate Target active

Input

int

0
Specify whether or not to activate the target when it is found.

Description

This X-function is used to either get the full Project Explorer path to a window (graph, workbook etc) or to activate a subfolder of the current folder in Project Explorer.

Examples

The example below utilizes four related X-Functions to reorganize an Origin project by creating and moving workbooks of imported data into folders that are named after the file extension of the files that were imported into the workbooks. The X-Functions that are used include: pe_cd, pe_mkdir, pe_path, and pe_move. Also illustrated is using the LabTalk document command as well as the String::GetFileExt()$ method.

// Use pe_cd X-function to change Project Explorer folder to the root folder for the Project.
pe_cd path:="/";

// Loop through every workbook in the project.
document -e W
{
	// Get the imported file name from page info tree of workbook (if it exists).
	string strFileName$ = page.info.system.import.filename$;
	
	// If the workboox does not contain imported data, the go to next workbook in loop.
	if (0 == strFileName.GetLength())
		continue;
		
	// Use the pe_mkdir X-Function to create a subfolder in the Project Explorer root folder named
	// after the file extension of the imported file. Note, the X-Function is specified to check
	// if the folder already exists before creating it.
	// strFolderPath$ will contain the full path once the X-Function returns.
	string strFolderPath$;
	pe_mkdir folder:="Imported %(strFileName.GetFileExt()$) Files" chk:=1 cd:=0 path:=strFolderPath$;
	
	// Now use the pe_path X-Function to get the full Project Explorer path to where the workbook currently resides.
	// strBookPath$ will contain the full path once the X-Function returns.
	string strBookPath$;
	pe_path page:="%(page.name$)" path:=strBookPath$ type:=0 active:=0;

	// Check to see if the workbook is already in the newly-created (or existing) folder by comparing the two paths.
	// If it is not, then use the pe_move X-Function to move the workbook into the folder from its current location.
	if (strBookPath$ != strFolderPath$)
		pe_move -sb move:="%(page.name$)" path:="%(strFolderPath$)";
}

Related X-Functions

pe_cd pe_dir pe_mkdir pe_move