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.
X-Function Execution Options
Please refer to the page for additional option switches when accessing the x-function from script
|Name of page or folder
|| 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.
|| 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.
|| Specify the type of the target: window or subfolder. See path variable for more information.
- window:Page Short Name
- Search for a window.
- folder:Subfolder Name
- Search for a subfolder.
|| Specify whether or not to activate the target when it is found.
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.
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.
// 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())
// 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.
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.
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$)";