The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 create consecutive nuber of folders
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

OndrejMM

Australia
81 Posts

Posted - 10/20/2010 :  01:36:17 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi guys, is there a way to create a consecutive number of folders using just labtalk? I would need to create a folder e.g. "1" with two sub-folders: "1a" and "1b", and in each sub-folder there need to be three worksheetsm, in sub-folder "1a": "a1a", "b1a", "c1a", and in the sub-folder "1b": "a1b", "b1b", "c1b", ... but then by importing another data set I would need to check if the folder "1" already exists and if "yes" then I would need to create a folder "2" with the same sub-folders and worksheets but instead of having "1" there will be "2",... any ideas how to do this? many thanks, ondrej

Sam Fang

293 Posts

Posted - 10/20/2010 :  06:43:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is an example for Origin8.5 to create 5 consecutive folders including subfolders with 3 worksheets in each subfolder. You can try it.

-----------------------------------------


//Specify strings of the suffix for subfolder and the preffix for worksheet names
StringArray sufstr, prestr;
sufstr.Add("a");
sufstr.Add("b");
prestr.Add("a");
prestr.Add("b");
prestr.Add("c");
//Folder Name
strfn$="1";
//Loop to create folders
for (i=1; i<=5; i++)
{
 //If the folder exists, it will use the next number as the new  folder's name.
 pe_mkdir folder:=strfn$ cd:=1 path:=strp$;
 //Get new folder's name from its path.
 strfn$=strp.GetToken(strp.GetNumTokens('/')-1, '/')$;
 string strsub;
 //Loop to create subfolders
 for(j=1; j<=2; j++)
 {
   strsub$=strfn$+sufstr.GetAt(j)$;
   pe_mkdir folder:=strsub$ cd:=1;
   newbook result:=bkname$ sheet:=0;
   string strwks;
   //Loop to add three worksheets for each subfolder
   for(k=1; k<=3; k++)
   {
      strwks$=prestr.GetAt(k)$+strsub$;
      newsheet book:=%(bkname$) name:=strwks$;
   }
   pe_cd ..;
 }
 //Set the next folder's name
 strfn$=$(%(strfn$)+1);
 pe_cd ..;
}


--------------------------------------------

Thanks.

Sam
OriginLab Technical Services

Edited by - Sam Fang on 10/21/2010 06:55:44 AM
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 10/20/2010 :  10:39:08 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Sam, thanks, this definitely helps, but the thing i'm still not sure of is checking the existence of a folder with a specific name,... e.g. if i run the script and i want to create a folder "1" but such folder might already exists, so i need to create folder "2",... is this possible? cheers, ondrej
Go to Top of Page

Sam Fang

293 Posts

Posted - 10/21/2010 :  07:05:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Ondrej,

I updated the script for Origin8.5 in the previous post. Now it can new a folder using the next number if current folder exists. You can have a try.

Thanks.

Note that in fact Origin8.5's X-Function pe_mkdir can new a folder using the next number if current folder exists by default.

Sam
OriginLab Technical Services

Edited by - Sam Fang on 10/21/2010 07:16:29 AM
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 10/21/2010 :  5:35:33 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks Sam, i'm going to play with it, ...
cheers, ondrej
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 10/24/2010 :  11:09:15 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Sam, i was playing with the script (see below), though i have a few problems which i'm sure can be solved,...

1) is it possible to somehow count the number of already existing folders in the root? because in the current script, when i just create a consecutive number of folders e.g. 1,2,3 everything is working fine, but when i rename e.g. folder "3" to something more appropriate the script fails, because it doesn't know that there is already folder "3" with workbooks which have number "3",...

2) do you know why I cannot set a line width in my graphs using the following line?

plotxy iy:=2 plot:=200 size:=5 color:=1 ogl:=[strgrp$]1!;

3) is there a way to copy text from a Note window into a label in a graph page?

many thanks,
odrej

// script

pe_cd("/"); //activate root folder

//Specify strings of the suffix for subfolder and the preffix for worksheet names
StringArray sufstr, prestr;
sufstr.Add("TTT");
sufstr.Add("CTT");
sufstr.Add("CC");
prestr.Add(".PCS");
prestr.Add(".PCF");
prestr.Add(".BCS");
prestr.Add(".BCF");
prestr.Add(".FC");
prestr.Add(".MS");


//Folder Name
strfn$="1";

//Loop to create folders
//for (i=1; i<=1; i++)
//{
//If the folder exists, it will use the next number as the new folder's name.
pe_mkdir folder:=strfn$ cd:=1 path:=strp$;
//Get new folder's name from its path.
strfn$=strp.GetToken(strp.GetNumTokens('/')-1, '/')$;


string strsub;
string strbok;
string strgrp;

//*********************************************************************************
//**************************** CREATE SUBFOLDER 1 (TTT) ***************************
//*********************************************************************************

//Loop to create subfolders

j=1; //create TTT subfolder
strsub$=strfn$ + "." + sufstr.GetAt(j)$; //define subfolder name
strbok$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name
strgrp$=sufstr.GetAt(j)$ + "graph" + strfn$; //define graph name

pe_mkdir folder:=strsub$ cd:=1; //create subfolder


//*********************************************************************************
//**************************** IMPORT TTT DIAGRAM DATA ****************************
//*********************************************************************************

newbook name:=strbok$ option:=lsname sheet:=0; // create a new workbook with shortname and longname "strbok$"

string strwks;

//Loop to add six worksheets for each subfolder
for(k=1; k<=6; k++)
{
strwks$=strsub$+prestr.GetAt(k)$;
newsheet book:=%(bkname$) name:=strwks$;
}

//PCS
page.active$ = 1; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=PCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
PCSTTTYS=cell(1,2);
PCSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCSTTTYE=cell(wks.col.nRows,2);

//PCF
page.active$ = 2; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=PCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCFTTTXS=cell(1,1); // START -TTT-Xaxis-Start
PCFTTTYS=cell(1,2);
PCFTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCFTTTYE=cell(wks.col.nRows,2);

//BCS
page.active$ = 3; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=BCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
BCSTTTYS=cell(1,2);
BCSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCSTTTYE=cell(wks.col.nRows,2);

//BCF
page.active$ = 4; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=BCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCFTTTXS=cell(1,1); // START -TTT-Xaxis-Start
BCFTTTYS=cell(1,2);
BCFTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCFTTTYE=cell(wks.col.nRows,2);

//FC
page.active$ = 5; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=FC.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
FCTTTXS=cell(1,1); // START -TTT-Xaxis-Start
FCTTTYS=cell(1,2);
FCTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
FCTTTYE=cell(wks.col.nRows,2);

//MS
page.active$ = 6; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=MS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
MSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
MSTTTYS=cell(1,2);
MSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
MSTTTYE=cell(wks.col.nRows,2);

pe_cd ..; //go one folder up

//*********************************************************************************
//**************************** CREATE GRAPH WINDOW ******************************
//*********************************************************************************

win -t plot MyTemplate %(strgrp$); // create a new graph window

// X
layer.x.type = 2; //Set the scale to Log10
layer.x.from = 0.1; //Set the start value
layer.x.to = 1000000; //Set the end value
layer.x.inc = 1; //Set the increment value
layer.x.labelSubtype = 2; //Tick label format: 1 = decimal, 2 = scientific, 3 = engineering (1K), and 4 = decimal (1,000).
label -xb Time [sec]; //Create a new, or replace the existing, bottom X axis title.

// Y
layer.y.type = 1; //Set the scale to Log10
layer.y.from = 300; //Set the start value
layer.y.to = 900; //Set the end value
layer.y.inc = 100; //Set the increment value
label -yl Temperature [C]; //Create a new, or replace the existing, left Y axis title.


//*********************************************************************************
//**************************** PLOT GRAPH DATA **********************************
//*********************************************************************************


//loop over all worksheets in the active workbook

win -o %(strbok$) {

for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=5 color:=1 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
}
};

//*********************************************************************************
//**************************** PLACE LABELS *************************************
//*********************************************************************************

// Calculate coordinates for placing labes

// B label
BTTTXA=(BCSTTTXS+BCFTTTXS)/5;
BTTTYA=(BCSTTTYS+BCSTTTYE)/2;
label -a (BTTTXA) (BTTTYA) \b(B); // place B

// F label
FTTTXA=(FCTTTXS+PCSTTTXS)/2;
FTTTYA=(FCTTTYS+FCTTTYE)/2;
label -a (FTTTXA) (FTTTYA) \b(F); // place F

// F+P
PTTTXA=(PCSTTTXS+PCFTTTXS)/2;
PTTTYA=(PCSTTTYS+PCSTTTYE)/2;
label -a (PTTTXA) (PTTTYA) \b(P); // place P

// A label
ATTTXA=(MSTTTXS+BCSTTTXS)/2;
ATTTYA=(MSTTTYS+FCTTTYE)/2;
label -a (ATTTXA) (ATTTYA) \b(A); // place A

// M label
MTTTXA=(MSTTTXS+BCSTTTXS)/2;
MTTTYA=(MSTTTYS-20);
label -a (MTTTXA) (MTTTYA) \b(M); // place M

label -r Legend; // delete legend

//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************



//*********************************************************************************
//**************************** CREATE SUBFOLDER 2 (CCT) ***************************
//*********************************************************************************

//Loop to create subfolders

j=2; //create TTT subfolder
strsub$=strfn$ + "." + sufstr.GetAt(j)$; //define subfolder name
strbok$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name
strgrp$=sufstr.GetAt(j)$ + "graph" + strfn$; //define graph name

pe_mkdir folder:=strsub$ cd:=1; //create subfolder


//*********************************************************************************
//**************************** IMPORT TTT DIAGRAM DATA ****************************
//*********************************************************************************

newbook name:=strbok$ option:=lsname sheet:=0; // create a new workbook with shortname and longname "strbok$"

string strwks;

//Loop to add six worksheets for each subfolder
for(k=1; k<=6; k++)
{
strwks$=strsub$+prestr.GetAt(k)$;
newsheet book:=%(bkname$) name:=strwks$;
}

//PCS
page.active$ = 1; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=PCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
PCSCCTYS=cell(1,2);
PCSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCSCCTYE=cell(wks.col.nRows,2);

//PCF
page.active$ = 2; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=PCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCFCCTXS=cell(1,1); // START -TTT-Xaxis-Start
PCFCCTYS=cell(1,2);
PCFCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCFCCTYE=cell(wks.col.nRows,2);

//BCS
page.active$ = 3; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=BCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
BCSCCTYS=cell(1,2);
BCSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCSCCTYE=cell(wks.col.nRows,2);

//BCF
page.active$ = 4; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=BCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCFCCTXS=cell(1,1); // START -TTT-Xaxis-Start
BCFCCTYS=cell(1,2);
BCFCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCFCCTYE=cell(wks.col.nRows,2);

//FC
page.active$ = 5; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=FC.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
FCCCTXS=cell(1,1); // START -TTT-Xaxis-Start
FCCCTYS=cell(1,2);
FCCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
FCCCTYE=cell(wks.col.nRows,2);

//MS
page.active$ = 6; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=MS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
MSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
MSCCTYS=cell(1,2);
MSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
MSCCTYE=cell(wks.col.nRows,2);

pe_cd ..; //go one folder up

//*********************************************************************************
//**************************** CREATE GRAPH WINDOW ******************************
//*********************************************************************************

win -t plot MyTemplate %(strgrp$); // create a new graph window

// X
layer.x.type = 2; //Set the scale to Log10
layer.x.from = 0.1; //Set the start value
layer.x.to = 1000000; //Set the end value
layer.x.inc = 1; //Set the increment value
layer.x.labelSubtype = 2; //Tick label format: 1 = decimal, 2 = scientific, 3 = engineering (1K), and 4 = decimal (1,000).
label -xb Time [sec]; //Create a new, or replace the existing, bottom X axis title.

// Y
layer.y.type = 1; //Set the scale to Log10
layer.y.from = 300; //Set the start value
layer.y.to = 900; //Set the end value
layer.y.inc = 100; //Set the increment value
label -yl Temperature [C]; //Create a new, or replace the existing, left Y axis title.


//*********************************************************************************
//**************************** PLOT GRAPH DATA **********************************
//*********************************************************************************


//loop over all worksheets in the active workbook

win -o %(strbok$) {

for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=5 color:=1 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
}
};


//*********************************************************************************
//**************************** PLACE LABELS *************************************
//*********************************************************************************

// B label
BCCTXA=(BCSCCTXS+BCFCCTXS)/2;
BCCTYA=(BCSCCTYS+BCSCCTYE)/2;
label -a (BCCTXA) (BCCTYA) \b(B); // place B

// F label
FCCTXA=(FCCCTXS+PCSCCTXS)/2;
FCCTYA=(FCCCTYS+FCCCTYE)/2;
label -a (FCCTXA) (FCCTYA) \b(F); // place F

// F+P
PCCTXA=(PCSCCTXS+PCFCCTXS)/2;
PCCTYA=(PCSCCTYS+PCSCCTYE)/2;
label -a (PCCTXA) (PCCTYA) \b(P); // place P

// A label
ACCTXA=(MSCCTXS+BCSCCTXS)/2;
ACCTYA=(MSCCTYS+FCCCTYE)/2;
label -a (ACCTXA) (ACCTYA) \b(A); // place A

// M label
MCCTXA=(MSCCTXS+BCSCCTXS)/2;
MCCTYA=(MSCCTYS-20);
label -a (MCCTXA) (MCCTYA) \b(M); // place M

label -r Legend; // delete legend

//*********************************************************************************
//**************************** IMPORT COOLING CURVES ******************************
//*********************************************************************************

j=3;
string strccbok;
strcc$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name for cooling curves

newbook name:=strcc$ option:=lsname hidden:=1; // create a new workbook with shortname and longname strccbo$

// import data into newly created workbook

win -o %(strcc$) {
string path$ = System.path.Origin$ + "CCT\CC"; // define the path where to look for the folder
findfiles f:=fns$ e:="*.txt"; // find matching files in 'path$'
int n = fns.GetNumTokens(CRLF); // Number of files found
impASC fname:=fns$ // impasc has many options
options.ImpMode:=4 // start with new sheet
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0; // do not rename the workbook
};

//loop over all worksheets in the active workbook
win -o %(strcc$) {
for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=2 color:=4 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
}
};

//*********************************************************************************
//**************************** MERGING GRAPHS *************************************
//*********************************************************************************

win -m; //merge all graphs
win -z; // maximaze graph
page.active=1; //active first layer
layer.width=40; // set layer's width
layer.height=45; // set layer's height
laysetpos left:=6 top:=20; // set layer 1 position

page.active=2; //active first layer
layer.width=40; // set layer's width
layer.height=45; // set layer's height
laysetpos left:=55 top:=20; // set layer 1 position
label -r Legend; // delete legend

string strname;
strname$="TTTCCTgraph" + strfn$;

win -r Graph2 %(strname$); //change shortname of Graph 1
page.longname$ ="TTTCCTgraph" + strfn$; //set long name for merged graph




//*********************************************************************************
//**************************** LOAD INPUT FILE ************************************
//*********************************************************************************

string path$ = System.path.Origin$; // define the path
open -n INPUT.txt; // open INPUT.txt
win -in INPUT.txt; // minimize window


win -rn INPUT.txt %(strname$); // set short name for notes window
page.longname$ ="TTTCCTgraph" + strfn$; //set long name for merged graph

win -o Layout1 {
Notes2Label(INPUT.txt); //copy note text to label
doc -uw; // refresh layout
};

win -cn INPUT.txt;
win -z Layout1;


Set the next folder's name
strfn$=$(%(strfn$)+1);
pe_cd ..;
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 10/26/2010 :  02:13:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
is there a way to create a consecutive number of folders but in the way that the folder name is in the following form "1.text" "2.text" "3.text",... so then if i want i can change the "text" part of the name to something more appropriate,...

here is my current script which works, but when i change folder name it crushes,...

many thanks,
ondrej


pe_cd("/"); //activate root folder

//Specify strings of the suffix for subfolder and the preffix for worksheet names
StringArray sufstr, prestr;
sufstr.Add("TTT");
sufstr.Add("CTT");
sufstr.Add("CC");
prestr.Add(".PCS");
prestr.Add(".PCF");
prestr.Add(".BCS");
prestr.Add(".BCF");
prestr.Add(".FC");
prestr.Add(".MS");


//Folder Name
strfn$="1";

//Loop to create folders
//for (i=1; i<=1; i++)
//{
//If the folder exists, it will use the next number as the new folder's name.
pe_mkdir folder:=strfn$ cd:=1 path:=strp$;
//Get new folder's name from its path.
strfn$=strp.GetToken(strp.GetNumTokens('/')-1, '/')$;


string strsub;
string strbok;
string strgrp;

//*********************************************************************************
//**************************** CREATE SUBFOLDER 1 (TTT) ***************************
//*********************************************************************************

//Loop to create subfolders

j=1; //create TTT subfolder
strsub$=strfn$ + "." + sufstr.GetAt(j)$; //define subfolder name
strbok$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name
strgrp$=sufstr.GetAt(j)$ + "graph" + strfn$; //define graph name

pe_mkdir folder:=strsub$ cd:=1; //create subfolder


//*********************************************************************************
//**************************** IMPORT TTT DIAGRAM DATA ****************************
//*********************************************************************************

newbook name:=strbok$ option:=lsname sheet:=0; // create a new workbook with shortname and longname "strbok$"

string strwks;

//Loop to add six worksheets for each subfolder
for(k=1; k<=6; k++)
{
strwks$=strsub$+prestr.GetAt(k)$;
newsheet book:=%(bkname$) name:=strwks$;
}

//PCS
page.active$ = 1; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=PCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
PCSTTTYS=cell(1,2);
PCSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCSTTTYE=cell(wks.col.nRows,2);

//PCF
page.active$ = 2; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=PCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCFTTTXS=cell(1,1); // START -TTT-Xaxis-Start
PCFTTTYS=cell(1,2);
PCFTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCFTTTYE=cell(wks.col.nRows,2);

//BCS
page.active$ = 3; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=BCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
BCSTTTYS=cell(1,2);
BCSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCSTTTYE=cell(wks.col.nRows,2);

//BCF
page.active$ = 4; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=BCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCFTTTXS=cell(1,1); // START -TTT-Xaxis-Start
BCFTTTYS=cell(1,2);
BCFTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCFTTTYE=cell(wks.col.nRows,2);

//FC
page.active$ = 5; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=FC.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
FCTTTXS=cell(1,1); // START -TTT-Xaxis-Start
FCTTTYS=cell(1,2);
FCTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
FCTTTYE=cell(wks.col.nRows,2);

//MS
page.active$ = 6; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=MS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
MSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
MSTTTYS=cell(1,2);
MSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
MSTTTYE=cell(wks.col.nRows,2);

pe_cd ..; //go one folder up

//*********************************************************************************
//**************************** CREATE GRAPH WINDOW ******************************
//*********************************************************************************

win -t plot MyTemplate %(strgrp$); // create a new graph window

// X
layer.x.type = 2; //Set the scale to Log10
layer.x.from = 0.1; //Set the start value
layer.x.to = 1000000; //Set the end value
layer.x.inc = 1; //Set the increment value
layer.x.labelSubtype = 2; //Tick label format: 1 = decimal, 2 = scientific, 3 = engineering (1K), and 4 = decimal (1,000).
label -xb Time [sec]; //Create a new, or replace the existing, bottom X axis title.

// Y
layer.y.type = 1; //Set the scale to Log10
layer.y.from = 300; //Set the start value
layer.y.to = 900; //Set the end value
layer.y.inc = 100; //Set the increment value
label -yl Temperature [C]; //Create a new, or replace the existing, left Y axis title.


//*********************************************************************************
//**************************** PLOT GRAPH DATA **********************************
//*********************************************************************************


//loop over all worksheets in the active workbook

win -o %(strbok$) {

for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=5 color:=1 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
}
};

//*********************************************************************************
//**************************** PLACE LABELS *************************************
//*********************************************************************************

// Calculate coordinates for placing labes

// B label
BTTTXA=(BCSTTTXS+BCFTTTXS)/5;
BTTTYA=(BCSTTTYS+BCSTTTYE)/2;
label -a (BTTTXA) (BTTTYA) \b(B); // place B

// F label
FTTTXA=(FCTTTXS+PCSTTTXS)/2;
FTTTYA=(FCTTTYS+FCTTTYE)/2;
label -a (FTTTXA) (FTTTYA) \b(F); // place F

// F+P
PTTTXA=(PCSTTTXS+PCFTTTXS)/2;
PTTTYA=(PCSTTTYS+PCSTTTYE)/2;
label -a (PTTTXA) (PTTTYA) \b(P); // place P

// A label
ATTTXA=(MSTTTXS+BCSTTTXS)/2;
ATTTYA=(MSTTTYS+FCTTTYE)/2;
label -a (ATTTXA) (ATTTYA) \b(A); // place A

// M label
MTTTXA=(MSTTTXS+BCSTTTXS)/2;
MTTTYA=(MSTTTYS-20);
label -a (MTTTXA) (MTTTYA) \b(M); // place M

label -r Legend; // delete legend

//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************



//*********************************************************************************
//**************************** CREATE SUBFOLDER 2 (CCT) ***************************
//*********************************************************************************

//Loop to create subfolders

j=2; //create TTT subfolder
strsub$=strfn$ + "." + sufstr.GetAt(j)$; //define subfolder name
strbok$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name
strgrp$=sufstr.GetAt(j)$ + "graph" + strfn$; //define graph name

pe_mkdir folder:=strsub$ cd:=1; //create subfolder


//*********************************************************************************
//**************************** IMPORT TTT DIAGRAM DATA ****************************
//*********************************************************************************

newbook name:=strbok$ option:=lsname sheet:=0; // create a new workbook with shortname and longname "strbok$"

string strwks;

//Loop to add six worksheets for each subfolder
for(k=1; k<=6; k++)
{
strwks$=strsub$+prestr.GetAt(k)$;
newsheet book:=%(bkname$) name:=strwks$;
}

//PCS
page.active$ = 1; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=PCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
PCSCCTYS=cell(1,2);
PCSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCSCCTYE=cell(wks.col.nRows,2);

//PCF
page.active$ = 2; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=PCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCFCCTXS=cell(1,1); // START -TTT-Xaxis-Start
PCFCCTYS=cell(1,2);
PCFCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCFCCTYE=cell(wks.col.nRows,2);

//BCS
page.active$ = 3; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=BCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
BCSCCTYS=cell(1,2);
BCSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCSCCTYE=cell(wks.col.nRows,2);

//BCF
page.active$ = 4; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=BCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCFCCTXS=cell(1,1); // START -TTT-Xaxis-Start
BCFCCTYS=cell(1,2);
BCFCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCFCCTYE=cell(wks.col.nRows,2);

//FC
page.active$ = 5; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=FC.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
FCCCTXS=cell(1,1); // START -TTT-Xaxis-Start
FCCCTYS=cell(1,2);
FCCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
FCCCTYE=cell(wks.col.nRows,2);

//MS
page.active$ = 6; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=MS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
MSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
MSCCTYS=cell(1,2);
MSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
MSCCTYE=cell(wks.col.nRows,2);

pe_cd ..; //go one folder up

//*********************************************************************************
//**************************** CREATE GRAPH WINDOW ******************************
//*********************************************************************************

win -t plot MyTemplate %(strgrp$); // create a new graph window

// X
layer.x.type = 2; //Set the scale to Log10
layer.x.from = 0.1; //Set the start value
layer.x.to = 1000000; //Set the end value
layer.x.inc = 1; //Set the increment value
layer.x.labelSubtype = 2; //Tick label format: 1 = decimal, 2 = scientific, 3 = engineering (1K), and 4 = decimal (1,000).
label -xb Time [sec]; //Create a new, or replace the existing, bottom X axis title.

// Y
layer.y.type = 1; //Set the scale to Log10
layer.y.from = 300; //Set the start value
layer.y.to = 900; //Set the end value
layer.y.inc = 100; //Set the increment value
label -yl Temperature [C]; //Create a new, or replace the existing, left Y axis title.


//*********************************************************************************
//**************************** PLOT GRAPH DATA **********************************
//*********************************************************************************


//loop over all worksheets in the active workbook

win -o %(strbok$) {

for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=5 color:=1 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
}
};


//*********************************************************************************
//**************************** PLACE LABELS *************************************
//*********************************************************************************

// B label
BCCTXA=(BCSCCTXS+BCFCCTXS)/2;
BCCTYA=(BCSCCTYS+BCSCCTYE)/2;
label -a (BCCTXA) (BCCTYA) \b(B); // place B

// F label
FCCTXA=(FCCCTXS+PCSCCTXS)/2;
FCCTYA=(FCCCTYS+FCCCTYE)/2;
label -a (FCCTXA) (FCCTYA) \b(F); // place F

// F+P
PCCTXA=(PCSCCTXS+PCFCCTXS)/2;
PCCTYA=(PCSCCTYS+PCSCCTYE)/2;
label -a (PCCTXA) (PCCTYA) \b(P); // place P

// A label
ACCTXA=(MSCCTXS+BCSCCTXS)/2;
ACCTYA=(MSCCTYS+FCCCTYE)/2;
label -a (ACCTXA) (ACCTYA) \b(A); // place A

// M label
MCCTXA=(MSCCTXS+BCSCCTXS)/2;
MCCTYA=(MSCCTYS-20);
label -a (MCCTXA) (MCCTYA) \b(M); // place M

label -r Legend; // delete legend

//*********************************************************************************
//**************************** IMPORT COOLING CURVES ******************************
//*********************************************************************************

j=3;
string strccbok;
strcc$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name for cooling curves

newbook name:=strcc$ option:=lsname hidden:=1; // create a new workbook with shortname and longname strccbo$

// import data into newly created workbook

win -o %(strcc$) {
string path$ = System.path.Origin$ + "CCT\CC"; // define the path where to look for the folder
findfiles f:=fns$ e:="*.txt"; // find matching files in 'path$'
int n = fns.GetNumTokens(CRLF); // Number of files found
impASC fname:=fns$ // impasc has many options
options.ImpMode:=4 // start with new sheet
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0; // do not rename the workbook
};

//loop over all worksheets in the active workbook
win -o %(strcc$) {
for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=2 color:=4 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
}
};

//*********************************************************************************
//**************************** MERGING GRAPHS *************************************
//*********************************************************************************

win -m; //merge all graphs
win -z; // maximaze graph
page.active=1; //active first layer
layer.width=40; // set layer's width
layer.height=45; // set layer's height
laysetpos left:=6 top:=8; // set layer 1 position

page.active=2; //active first layer
layer.width=40; // set layer's width
layer.height=45; // set layer's height
laysetpos left:=55 top:=8; // set layer 1 position
label -r Legend; // delete legend

string strname;
strname$="TTTCCTgraph" + strfn$; // define graph name

win -r Graph2 %(strname$); //change shortname of Graph 1
page.longname$ ="TTTCCTgraph" + strfn$; //set long name for merged graph


page.active=1; //active first layer
label -n xxx \p60(INPUT); //create label with name 'xxx' (INPUT label)


//*********************************************************************************
//**************************** LOAD INPUT FILE ************************************
//*********************************************************************************

string path$ = System.path.Origin$; // define the path
open -n INPUT.txt; // open INPUT.txt
win -in INPUT.txt; // minimize window

string strnote;
strnote$="InputNote" + strfn$; // define notes window name

string strname;
strname$="TTTCCTgraph" + strfn$; // define graph name

win -z %(strname$);

win -rn INPUT.txt %(strnote$); // set short name for notes window

win -o %(strname$) {
NotesToLabel(%(strnote$)); //copy note text to label
doc -uw; // refresh layout
};


//position label
GObject lbl = xxx; // deinfe lbl varialbe = object name
lbl.fsize = 14; // change font size
lbl.top = 3000; // top position
lbl.left = 250; // left position


//win -cn %(strnote$);



Set the next folder's name
strfn$=$(%(strfn$)+1);
pe_cd ..;






Go to Top of Page

Sam Fang

293 Posts

Posted - 10/27/2010 :  07:00:50 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
1. You can use "exist" function to detect whether the folder 3 exists in the root before you rename.
-----------------------------------------

pe_cd /;
if(exist("3",25) == 0)
{
  //Folder 3 doesn't exist in root's folders. You can rename a folder as 3 now.
}

-----------------------------------------


2. size in plotxy is to specify Symbol Size, not line width. you can use
--------------------------
set %C -w 2500;

--------------------------
to change current plot's line to 5. (500 = 1 point)

Sam
OriginLab Technical Services

Edited by - Sam Fang on 10/27/2010 07:02:46 AM
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 10/28/2010 :  12:34:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Sam many thanks for the reply everything works for me except creating those folders, i cannot always check if the particular folder name exists,... therefore i would need to do the same what we are doing now but instead of creating folders 1,2,3 ... n and need to create folders 1.text, 2.text, 3.text, ... n.text - so if i want i can change "text into something else, but I will always keep the number there so i don't lose count,... i think that is only way i can think of which would do what I need,... would it be possible to script something like this? many thanks, ondrej
Go to Top of Page

Sam Fang

293 Posts

Posted - 10/29/2010 :  04:33:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
1. You can use following script to count current active folder's subfolders. pe_dir returns a list of subfolders and pages. Each folder follows a string "<Folder>" in the list. So we can determine number of subfolders by '<'.
--------------------------------------------
pe_dir oname:=strf$;
nsubf=strf.count('<');

---------------------------------------------

2. You can use the following script to create a subfolder "1.txt" in current folder. If "1.txt" exists, it will use the next number. And "i" records the number you should use. The new subfolder will be the active folder.
----------------------------------------------------------
i=1;
strfn$=$(i);
strfn$=strfn$+".txt";
for(; exist(strfn$,25); )
{
    i=i+1;
    strfn$=$(i);
    strfn$=strfn$+".txt";
}
pe_mkdir folder:=strfn$ cd:=1;

-----------------------------------------------------------

Sam
OriginLab Technical Services
Go to Top of Page

OndrejMM

Australia
81 Posts

Posted - 11/01/2010 :  10:58:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thank you Sam, it all works,... i've changed it a bit but the idea is the same,... here is the finial script if someone find it useful,... cheers, ondrej



pe_cd("/"); //activate root folder

//Specify strings of the suffix for subfolder and the preffix for worksheet names
StringArray sufstr, prestr;
sufstr.Add("TTT");
sufstr.Add("CTT");
sufstr.Add("CC");
prestr.Add(".PCS");
prestr.Add(".PCF");
prestr.Add(".BCS");
prestr.Add(".BCF");
prestr.Add(".FC");
prestr.Add(".MS");


// you can use following script to count current active folder's subfolders. pe_dir returns a list of subfolders and pages.
//Each folder follows a string "<Folder>" in the list. So we can determine number of subfolders by '<'.

pe_dir oname:=strf$;
nsubf=strf.count('<');



strfn$=$(nsubf + 1); // add one to number of subfolders
strfo$=strfn$+".text"; // create name for the subfolder

//for(; exist(strfo$,25); )
//{
//i=i+1;
//strfn$=$(i);
//strfo$=strfn$+".txt";
//}

pe_mkdir folder:=strfo$ cd:=1; // create subfolder

//i=1;
//strfn$=$(i);
//strfn$=strfn$+".text";
//for(; exist(strfn$,25); )
//{
//i=i+1;
//strfn$=$(i);
//strfo$=strfn$+".text";
//
//
//}
//pe_mkdir folder:=strfn$ cd:=1;
//


//Folder Name
//strfn$="1";

//Loop to create folders
//for (i=1; i<=1; i++)
//{
//If the folder exists, it will use the next number as the new folder's name.
//pe_mkdir folder:=strfn$ cd:=1 path:=strp$;
//Get new folder's name from its path.
//strfn$=strp.GetToken(strp.GetNumTokens('/')-1, '/')$;


string strsub;
string strbok;
string strgrp;

//*********************************************************************************
//**************************** CREATE SUBFOLDER 1 (TTT) ***************************
//*********************************************************************************

//Loop to create subfolders

j=1; //create TTT subfolder
strsub$=strfn$ + "." + sufstr.GetAt(j)$; //define subfolder name
strbok$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name
strgrp$=sufstr.GetAt(j)$ + "graph" + strfn$; //define graph name

pe_mkdir folder:=strsub$ cd:=1; //create subfolder



//*********************************************************************************
//**************************** IMPORT TTT DIAGRAM DATA ****************************
//*********************************************************************************

newbook name:=strbok$ option:=lsname sheet:=0; // create a new workbook with shortname and longname "strbok$"

string strwks;

//Loop to add six worksheets for each subfolder
for(k=1; k<=6; k++)
{
strwks$=strsub$+prestr.GetAt(k)$;
newsheet book:=%(bkname$) name:=strwks$;
}

//PCS
page.active$ = 1; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=PCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments





//get numbers for labels
PCSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
PCSTTTYS=cell(1,2);
PCSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCSTTTYE=cell(wks.col.nRows,2);

//PCF
page.active$ = 2; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=PCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCFTTTXS=cell(1,1); // START -TTT-Xaxis-Start
PCFTTTYS=cell(1,2);
PCFTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCFTTTYE=cell(wks.col.nRows,2);

//BCS
page.active$ = 3; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=BCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
BCSTTTYS=cell(1,2);
BCSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCSTTTYE=cell(wks.col.nRows,2);

//BCF
page.active$ = 4; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=BCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCFTTTXS=cell(1,1); // START -TTT-Xaxis-Start
BCFTTTYS=cell(1,2);
BCFTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCFTTTYE=cell(wks.col.nRows,2);

//FC
page.active$ = 5; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=FC.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
FCTTTXS=cell(1,1); // START -TTT-Xaxis-Start
FCTTTYS=cell(1,2);
FCTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
FCTTTYE=cell(wks.col.nRows,2);

//MS
page.active$ = 6; // active worksheet by name
string path$ = System.path.Origin$ + "TTT\";
findFiles ext:=MS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
MSTTTXS=cell(1,1); // START -TTT-Xaxis-Start
MSTTTYS=cell(1,2);
MSTTTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
MSTTTYE=cell(wks.col.nRows,2);

pe_cd ..; //go one folder up



//*********************************************************************************
//**************************** CREATE GRAPH WINDOW ******************************
//*********************************************************************************

win -t plot MyTemplate %(strgrp$); // create a new graph window

// X
layer.x.type = 2; //Set the scale to Log10
layer.x.from = 0.1; //Set the start value
layer.x.to = 1000000; //Set the end value
layer.x.inc = 1; //Set the increment value
layer.x.labelSubtype = 2; //Tick label format: 1 = decimal, 2 = scientific, 3 = engineering (1K), and 4 = decimal (1,000).
label -xb Time [sec]; //Create a new, or replace the existing, bottom X axis title.

// Y
layer.y.type = 1; //Set the scale to Log10
layer.y.from = 300; //Set the start value
layer.y.to = 900; //Set the end value
layer.y.inc = 100; //Set the increment value
label -yl Temperature [C]; //Create a new, or replace the existing, left Y axis title.


//*********************************************************************************
//**************************** PLOT GRAPH DATA **********************************
//*********************************************************************************


//loop over all worksheets in the active workbook

win -o %(strbok$) {

for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=5 color:=1 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
//set %C -w 1000;
}
};

//*********************************************************************************
//**************************** PLACE LABELS *************************************
//*********************************************************************************

// Calculate coordinates for placing labes

// B label
BTTTXA=(BCSTTTXS+BCFTTTXS)/5;
BTTTYA=(BCSTTTYS+BCSTTTYE)/2;
label -a (BTTTXA) (BTTTYA) \b(B); // place B

// F label
FTTTXA=(FCTTTXS+PCSTTTXS)/2;
FTTTYA=(FCTTTYS+FCTTTYE)/2;
label -a (FTTTXA) (FTTTYA) \b(F); // place F

// F+P
PTTTXA=(PCSTTTXS+PCFTTTXS)/2;
PTTTYA=(PCSTTTYS+PCSTTTYE)/2;
label -a (PTTTXA) (PTTTYA) \b(P); // place P

// A label
ATTTXA=(MSTTTXS+BCSTTTXS)/2;
ATTTYA=(MSTTTYS+FCTTTYE)/2;
label -a (ATTTXA) (ATTTYA) \b(A); // place A

// M label
MTTTXA=(MSTTTXS+BCSTTTXS)/2;
MTTTYA=(MSTTTYS-20);
label -a (MTTTXA) (MTTTYA) \b(M); // place M

label -r Legend; // delete legend

//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************
//***************************************************************************************************************************************************************


//*********************************************************************************
//**************************** CREATE SUBFOLDER 2 (CCT) ***************************
//*********************************************************************************

//Loop to create subfolders

j=2; //create TTT subfolder
strsub$=strfn$ + "." + sufstr.GetAt(j)$; //define subfolder name
strbok$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name
strgrp$=sufstr.GetAt(j)$ + "graph" + strfn$; //define graph name

pe_mkdir folder:=strsub$ cd:=1; //create subfolder


//*********************************************************************************
//**************************** IMPORT TTT DIAGRAM DATA ****************************
//*********************************************************************************

newbook name:=strbok$ option:=lsname sheet:=0; // create a new workbook with shortname and longname "strbok$"

string strwks;

//Loop to add six worksheets for each subfolder
for(k=1; k<=6; k++)
{
strwks$=strsub$+prestr.GetAt(k)$;
newsheet book:=%(bkname$) name:=strwks$;
}

//PCS
page.active$ = 1; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=PCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
PCSCCTYS=cell(1,2);
PCSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCSCCTYE=cell(wks.col.nRows,2);

//PCF
page.active$ = 2; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=PCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
PCFCCTXS=cell(1,1); // START -TTT-Xaxis-Start
PCFCCTYS=cell(1,2);
PCFCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
PCFCCTYE=cell(wks.col.nRows,2);

//BCS
page.active$ = 3; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=BCS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
BCSCCTYS=cell(1,2);
BCSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCSCCTYE=cell(wks.col.nRows,2);

//BCF
page.active$ = 4; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=BCF.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
BCFCCTXS=cell(1,1); // START -TTT-Xaxis-Start
BCFCCTYS=cell(1,2);
BCFCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
BCFCCTYE=cell(wks.col.nRows,2);

//FC
page.active$ = 5; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=FC.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
FCCCTXS=cell(1,1); // START -TTT-Xaxis-Start
FCCCTYS=cell(1,2);
FCCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
FCCCTYE=cell(wks.col.nRows,2);

//MS
page.active$ = 6; // active worksheet by name
string path$ = System.path.Origin$ + "CCT\";
findFiles ext:=MS.txt;
impASC
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0 // DON'T rename the workbook
options.Names.FNameToSht:= 0 // DON'T rename worksheet
options.Names.FPathToComm:=1; // include file path to comments

//get numbers for labels
MSCCTXS=cell(1,1); // START -TTT-Xaxis-Start
MSCCTYS=cell(1,2);
MSCCTXE=cell(wks.col.nRows,1); // END -TTT-Xaxis-End
MSCCTYE=cell(wks.col.nRows,2);

pe_cd ..; //go one folder up

//*********************************************************************************
//**************************** CREATE GRAPH WINDOW ******************************
//*********************************************************************************

win -t plot MyTemplate %(strgrp$); // create a new graph window

// X
layer.x.type = 2; //Set the scale to Log10
layer.x.from = 0.1; //Set the start value
layer.x.to = 1000000; //Set the end value
layer.x.inc = 1; //Set the increment value
layer.x.labelSubtype = 2; //Tick label format: 1 = decimal, 2 = scientific, 3 = engineering (1K), and 4 = decimal (1,000).
label -xb Time [sec]; //Create a new, or replace the existing, bottom X axis title.

// Y
layer.y.type = 1; //Set the scale to Log10
layer.y.from = 300; //Set the start value
layer.y.to = 900; //Set the end value
layer.y.inc = 100; //Set the increment value
label -yl Temperature [C]; //Create a new, or replace the existing, left Y axis title.


//*********************************************************************************
//**************************** PLOT GRAPH DATA **********************************
//*********************************************************************************


//loop over all worksheets in the active workbook

win -o %(strbok$) {

for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=5 color:=1 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
}
};


//*********************************************************************************
//**************************** PLACE LABELS *************************************
//*********************************************************************************

// B label
BCCTXA=(BCSCCTXS+BCFCCTXS)/2;
BCCTYA=(BCSCCTYS+BCSCCTYE)/2;
label -a (BCCTXA) (BCCTYA) \b(B); // place B

// F label
FCCTXA=(FCCCTXS+PCSCCTXS)/2;
FCCTYA=(FCCCTYS+FCCCTYE)/2;
label -a (FCCTXA) (FCCTYA) \b(F); // place F

// F+P
PCCTXA=(PCSCCTXS+PCFCCTXS)/2;
PCCTYA=(PCSCCTYS+PCSCCTYE)/2;
label -a (PCCTXA) (PCCTYA) \b(P); // place P

// A label
ACCTXA=(MSCCTXS+BCSCCTXS)/2;
ACCTYA=(MSCCTYS+FCCCTYE)/2;
label -a (ACCTXA) (ACCTYA) \b(A); // place A

// M label
MCCTXA=(MSCCTXS+BCSCCTXS)/2;
MCCTYA=(MSCCTYS-20);
label -a (MCCTXA) (MCCTYA) \b(M); // place M

label -r Legend; // delete legend

//*********************************************************************************
//**************************** IMPORT COOLING CURVES ******************************
//*********************************************************************************

j=3;
string strccbok;
strcc$=sufstr.GetAt(j)$ + "book" + strfn$; //define workbook name for cooling curves

newbook name:=strcc$ option:=lsname hidden:=1; // create a new workbook with shortname and longname strccbo$

// import data into newly created workbook

win -o %(strcc$) {
string path$ = System.path.Origin$ + "CCT\CC"; // define the path where to look for the folder
findfiles f:=fns$ e:="*.txt"; // find matching files in 'path$'
int n = fns.GetNumTokens(CRLF); // Number of files found
impASC fname:=fns$ // impasc has many options
options.ImpMode:=4 // start with new sheet
options.Sparklines:=1 // turn on sparklines
options.Names.AutoNames:=0 // turn off auto rename
options.Names.FNameToBk:=0; // do not rename the workbook
};

//loop over all worksheets in the active workbook
win -o %(strcc$) {
for( laynum = 1 ; laynum <= page.nlayers ; laynum++ ) // loop over all worksheets
{
page.active = laynum; // make a worksheet active
plotxy iy:=2 plot:=200 size:=2 color:=4 ogl:=[strgrp$]1!; // plot XY data inot existing graph, layer 2
}
};
//set -w 1000; // this suppose to define line tickness

//*********************************************************************************
//**************************** MERGING GRAPHS *************************************
//*********************************************************************************

win -m; //merge all graphs
win -z; // maximaze graph
page.active=1; //active first layer
layer.width=40; // set layer's width
layer.height=45; // set layer's height
laysetpos left:=6 top:=8; // set layer 1 position

page.active=2; //active first layer
layer.width=40; // set layer's width
layer.height=45; // set layer's height
laysetpos left:=55 top:=8; // set layer 1 position
label -r Legend; // delete legend

string strname;
strname$="TTTCCTgraph" + strfn$; // define graph name

win -r Graph2 %(strname$); //change shortname of Graph 1
page.longname$ ="TTTCCTgraph" + strfn$; //set long name for merged graph


page.active=1; //active first layer
label -n xxx \p60(INPUT); //create label with name 'xxx' (INPUT label)


//*********************************************************************************
//**************************** LOAD INPUT FILE ************************************
//*********************************************************************************

string path$ = System.path.Origin$; // define the path
open -n INPUT.txt; // open INPUT.txt
win -in INPUT.txt; // minimize window

string strnote;
strnote$="InputNote" + strfn$; // define notes window name

string strname;
strname$="TTTCCTgraph" + strfn$; // define graph name

string strname;

win -rn INPUT.txt %(strnote$); // set short name for notes window

win -z %(strname$);
NotesToLabel(%(strnote$)); //copy note text to label
doc -uw; // refresh layout
//};


//position label
GObject lbl = xxx; // deinfe lbl varialbe = object name
lbl.fsize = 14; // change font size
lbl.top = 3000; // top position
lbl.left = 250; // left position


//win -cn %(strnote$); //delete note window

//Set the next folder's name
//strfn$=$(%(strfn$)+1);





Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000