Thanks Don improvements in scripting i have update my "Store and Load Tabs as session"-script.
Sessions20100724.xys
Need latest XYplorer BETA version (v9.30.0012, 24-jul-2010) or any newer one.
Code: Select all
deleted
works only partly since i understood the syntax wrong
Sessions20100725.xys
Needs latest XYplorer BETA version (v9.30.0014, 25-jul-2010) or newer
Code: Select all
deleted
was too slow and stupid to change the tab to get the info.
Sessions20100728.xys
Needs latest XYplorer BETA version (v9.30.0014, 25-jul-2010) or newer
Change log:
- No need to change tabs to get the info, just use
tab(,,index) now.
+ add an sessions\sub-folder "ComputerName" for better handling of portable use
+ add an function to allow you to add an comment to your session file (in addition to modify the file name by an comment)
* change session file name to YYYMMDD HHNN_PaneX. You may modify $DefaultFileName to your needs if you prefer an other file name.
Code: Select all
//needs latest XYplorer BETA version (v9.30.0014, 25-jul-2010) or newer
//Note: depending on your XY settings something may not work as indented.
// save an list of current open Tabs from current pane to an file:
"Store Session/Tabs"
$SubFolderName = "%computername%"; //"Work"; //sub-folder in sessions-folder
$TabCount = tab(,"c"); //how many tabs are open?
$Pane = getinfo("Pane"); //which pane is active?
$Loop = 0;
$Tabs = "";
while ($Loop<$TabCount) //for each tab do
{
//if (strlen(tab("get","name") < 1)
$IFTabNameSet = strlen(tab("get","name",$Loop));
if ($IFTabNameSet < 1)
{
$Tabs = $Tabs . tab("get", "data", $Loop) . "|"; //save the path in array "$Tabs" with | as delimiter
}else{
$Tabs = $Tabs . tab("get", "data", $Loop) . "?" . tab("get", "name", $Loop) . "|"; //save the tab caption too
}
incr $Loop;
}
//save the array to an file:
//$folder = inputfolder("<xydata>\sessions", "Select Folder");
IF (exists("<xydata>\Sessions\$SubFolderName")==0) {new "<xydata>\Sessions\$SubFolderName", dir;}
$DefaultFileName = "<xydata>\Sessions\$SubFolderName\<date yyyymmdd hhnn>_Pane" . $Pane . ".ini";
//
$SessionFile = Input("Save Session", "Save list of tabs as: (you may add an description into the file name)", $DefaultFileName);
//$SessionFile = $DefaultFileName;
//
writefile($SessionFile, $Tabs, "o");
$Comment = Input("Session comment", "Enter an comment for this session (optional)",,"s","");
comment $Comment, $SessionFile;
// ///////////////////////////////////////////////////////////////////////
// open new tabs from an list of paths (saved tabs):
"Load Session/Tabs"
//read session file into array "$Tabs":
$SubFolderName = "%computername%"; //"Work"; //sub-folder in sessions-folder
$SessionFile = inputfile("<xydata>\Sessions\$SubFolderName", "ini", "Load list of tabs");
$Tabs = readfile($SessionFile);
$Loop = 1;
//a little bit clean up first?
$CloseCurrentOpenTabs = confirm("Close current open tabs first?");
if ($CloseCurrentOpenTabs==0) { ;} elseif (tab(,"c")>1) {#353;} //close all "other" tabs
$Loop = 1;
While(1)
{
$NewTab = gettoken($Tabs,$Loop,"|");
if ($NewTab==""){break;}
if (strpos($NewTab,"?") == -1)
{
tab("new", $NewTab); //open new tab with next token from array
}else{
tab("new", gettoken($NewTab,1,"?"));
tab("rename", gettoken($NewTab,2,"?"));
}
incr $Loop;
}
if ($CloseCurrentOpenTabs==1){seltab 1;#351;} //close last "old" tab too
-
"Edit this &script : edit"
self $ScriptFile, file;
//OpenWith "<xypath>\Tools\NotePad2\Notepad2.exe", ,$ScriptFile;
OpenWith "Notepad", ,$ScriptFile;
Thank you Don!
Find me: save tab save tabs save session save sessions store tabs load tabs load session save project