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
 Getname from worksheet & getdata from ASCI file
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Loick

France
14 Posts

Posted - 03/11/2009 :  05:18:38 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Dear all,

I am currently writing a script in labtalk with the aim to import ASCI files and format them.

Here it is :

quote:
[plotloop]

getfile -m *.dat; // prompt for multiple files

for (i = 1; i <= count; i ++)

{
getfile -g i; // get the ith file into %A
create "data"$(i) -w 2;
open -w %A; // print it out in the Script window


work -n 2 Lum; //rename column 2 by Lum
work -n 3 Volt; //rename column 3 by Volt
work -n 4 NormLum; //rename column 4 by Normlum
work -n 5 VolInc; //rename column 5 by VolInc

col(NormLum) = col(Lum);
sum(col(NormLum)); //normalize the column by the highest value
col(NormLum)=col(Lum)/sum.max; //normalize the column by the highest value
sum(col(Volt)); //normalize the column by the highest value
col(VolInc)=col(volt)-sum.min; //normalize the column by the highest value

};

loop (ii, 2, 5)

{
%B = data1!wks.col$(ii).name$; //assign column ii name to %B
win -t plot %B; //open graph from %B template where the template correspond to the name of the column
layer -i data1_%B data2_%B data3_%B Data4_%B; //add data to layer
layer -g; //groupe all curve in the graph
layer -a; //rescale axes to show all data

}



So, my question is : how can I get the name from a worksheet after import it and store the name in a variable as %G (for example)?

I've tried this :

win -b worksheet2! //activate wks2
GetNamedWks %C //get name from the wks

But for sure it doesn't work.



Another question about the ASCI file. When I import it, how can I pic up some information and store them in a worksheet (info are in red color)?

The ASCI file has the following shape :

quote:
Sample : XX_XXXXXX_X_X_x_X12
Comment : MV: MV: xxxxxx_xxx: xxx:xxx:xxxx (XX:XX:X);; 60, 80, 120, 160 mA/cm², @85° C
Measurement started on : 09.01.09 15:02:25
SerialNo. : 0-0
Rack no. : 3
Port no. : 4
Driver no. : 1
Measuring interval [s] :
Pause log :
Accumulated pause time [s] : 0
System identification : xxxxxxxxxxxxx

[Driving parameters]
Driver operation : DC
Period [ms] : 10
On-Time [ms] : 10
Initial brightness [cd/m²] : xxxx,xx
Foreward setpoint : Constant current
Foreward current setpoint [mA] : 4,02
Foreward voltage setpoint : ---
Backward voltage setpoint : ---
Lum-factor [(cd/m²)/mV] : x,xx
OLED area [mm²] : a,aa
Smart-Save deviation [%] : 2,00
Smart-Save interval [h] : 10,00



Thanks a lot for your help. If there is something unclear, just tell me.


Loick



Loick

France
14 Posts

Posted - 03/11/2009 :  05:21:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Origin Ver. and Service Release (Select Help-->About Origin): 7,5
Operating System: XP pro

Some more info :)
Go to Top of Page

Loick

France
14 Posts

Posted - 03/13/2009 :  08:47:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

At least I have found many things by myself on the origin forum and origin help. So I have build this code.

I post it with the aim to help other origin users. Hope you will find some interesting things in it.



quote:

/*------------------------------------------------------------------------------*
* File Name: Lifetime *
* Creation: 03/2009 *
* Purpose: OriginLab Labtalk script for Lifetime data analysis *
* *
* Made by Loick-Alexandre GAUTIER *
* In colaboration with Philipp SCHWAMB *
* *
*------------------------------------------------------------------------------*/

[plotloop85]


getfile -m *.dat; // prompt for multiple files

create title -s count; //create variable named "title1, title2, title3... titlecount"

for (i = 1; i <= count; i ++) //Count = number of opened files

{
getfile -g i; // get the ith file into %A
create "data"$(i) -w 2; // create a wks named data1, data2, data3...
open -w %A; // print it out in the Script window

work -n 2 Lum; //rename column 2 by Lum
work -n 3 Volt; //rename column 3 by Volt
work -n 4 NormLum; //rename column 4 by Normlum
work -n 5 VolInc; //rename column 5 by VolInc

col(NormLum) = col(Lum);
sum(col(NormLum)); //normalize the column by the highest value
col(NormLum)=col(Lum)/sum.max; //normalize the column by the highest value
sum(col(Volt)); //normalize the column by the highest value
col(VolInc)=col(volt)-sum.min; //normalize the column by the highest value

create "header"$(i) -w 2; // create a wks named header1, header2, header3...

//following line are used to set the ASCII import filter with the aim to get the data from the header ASCII part

ascimport.GetSettings(); // read import settings
ascimport.renamewks=0; // avoid worksheet name change
Ascimport.HeaderLines=0; // number of header line to avoid befor importing data
Ascimport.AutoSubHeaderLines=0; // cancel autoheaderline
Ascimport.Delimiter=4; // set delimiter as other
Ascimport.Character$=":"; // set other as ":"
ascimport.Partial.C1=1; // Import from column 1
ascimport.Partial.C2=3; // to column 3
ascimport.Partial.R1=1; // Import from row 1
ascimport.Partial.R2=26; // to row 26
ascimport.partial=1; // use partial import

ascimport.WriteSettings(); // write import settings


open -w %A; // print it out in the Script window

U = %H!cell(19, 2); // set variable U = cell from wks col.2 row.19 (Foreward current setpoint [mA])
V = %H!cell(23, 2); // set variable V = cell from wks col.2 row.23 (OLED area [mm²])

%T = $(U/V*100); // calculate the current density applied and store it as %T (mA/cm²)

title[i]$ = %T; // set title1, title2... = to the variable %T

%H!cell(26, 1) = "current density"; // create a new cell col.1 row.26 "current density"
%H!cell(26, 2) = "%T mA/cm²"; // create a new cell col.2 row.26 "%T mA/cm²"

}

for (v = 1; v<= count; v+4)

{

loop (ii, 2, 5)

{

%B = data1!wks.col$(ii).name$; //assign column ii name to %B
%D = "%B85"; // set the %D variable = to name of column ii followed by 85 (ex:lum85)

%L = title$;
%M = title[v+1]$;
%N = title[v+2]$;
%O = title[v+3]$;


win -t plot %D; //open graph from %D template where the template correspond to the name of the column
layer -i data$(v)_%B data$(v+1)_%B data$(v+2)_%B Data$(v+3)_%B; //add data to layer
layer -g; //groupe all curve in the graph
layer -a; //rescale axes to show all data


//create some condition with the aim to well organise the curves in the graph. 60 mA/cm², 80 mA/cm², 120 mA/cm², 160 mA/cm²

{
{
if (%L == 60)
{
set data$(v)_%B -c 1;
%couleurlegend1 = 1;
}
else
if (%L == 80)
{
set data$(v)_%B -c 2;
%couleurlegend1 = 2;
}
else
if (%L == 120)
{
set data$(v)_%B -c 3;
%couleurlegend1 = 3;
}
else
if (%L == 160)
{
set data$(v)_%B -c 4;
%couleurlegend1 = 4;
}
};

{
if (%M == 60)
{
set data$(v+1)_%B -c 1;
%couleurlegend2 = 1;
}
else
if (%M == 80)
{
set data$(v+1)_%B -c 2;
%couleurlegend2 = 2;
}
else
if (%M == 120)
{
set data$(v+1)_%B -c 3;
%couleurlegend2 = 3;
}
else
if (%M == 160)
{
set data$(v+1)_%B -c 4;
%couleurlegend2 = 4;
}
};

{
if (%N == 60)
{
set data$(v+2)_%B -c 1;
%couleurlegend3 = 1;
}
else
if (%N == 80)
{
set data$(v+2)_%B -c 2;
%couleurlegend3 = 2;
}
else
if (%N == 120)
{
set data$(v+2)_%B -c 3;
%couleurlegend3 = 3;
}
else
if (%N == 160)
{
set data$(v+2)_%B -c 4;
%couleurlegend3 = 4;
}
};

{
if (%O == 60)
{
set data$(v+3)_%B -c 1;
%couleurlegend4 = 1;
}
else
if (%O == 80)
{
set data$(v+3)_%B -c 2;
%couleurlegend4 = 2;
}
else
if (%O == 120)
{
set data$(v+3)_%B -c 3;
%couleurlegend4 = 3;
}
else
if (%O == 160)
{
set data$(v+3)_%B -c 4;
%couleurlegend4 = 4;
}
};
}


legend -s; // create a legend textbox
legend.text$ = "\l(1) %L mA/cm²
\l(2) %M mA/cm²
\l(3) %N mA/cm²
\l(4) %O mA/cm²"; // edit the legend text
label -b 2; [green]// set the border line of legend to black line


}
}




I will also explain you how to create a button which will run your script.

1) Open origin.
2) Remove all column from the initial opened datasheet
3) then right click in the datasheet and "add text..."
4) Write the name of your button (ex:import data).
5) Right click on the text => "label control..."
6) In the dialog box : - Script run after (choose button up)
- in the text box just bellow, right the following command "run.section(LifeTime,plotloop85)"

Where "LifeTime" is the name of the script file and "Plotloop85" the name of the section that origin must run after clicking the button.

In my case it is at the beginning of my code [plotloop85]

7) Press OK, the button will be created.


Important Note:
1) You have to open the "codebuilder" windows (View => code builder or press Alt+4)
2) Add your file to the project (left side "originC workspace")
- Right click on "project Folder" and "add files..."


Hope I am clear enough... If you have any question on my code, fell free to ask me.

+++
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