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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Replacing data in several layers

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Baertram0815 Posted - 02/15/2006 : 05:32:39 AM
Origin Version (Select Help-->About Origin): 7GSR2
Operating System: XP

Hi,

I am starting with programming LabTalk in Origin. So I am a true Rookie in this filed. After checking out this forum and looking into the LabTalk help I am wondering about a fact I am not able to understand.
Hereīs my problem:

I have a worksheet with 24 columns of wich the first one (A) is a date and the following ones (B to X) are data to be plotted. As each column contains about 60 000 values I decided to plot the data in several graphs. As the column A contains the date in 18 different time regions I generated 18 Graphs. After I had generated these 18 Graphs I saved this File. These 18 graphs contain only one column, e. g. column B. How can I replace this column B with column C and so one and place the graphs in a new folder within the origin project automatically?

The way I tried to solve the problem (of course I have no idea of how to copy the generated graphs in a new folder!) was

//assume that column b actually is plotted and column c should
//be plotted now in Graphs 1 to 18
Graph1!page.active = 1
layer -c;
layer -e %Z;
layer -i200 data1_c
//Go on to the next Graph. I donīt know how to do this in a
//loop for all Graphs

I think the first command should acitvate Layer 1 from Graph 1. But this doesnīt work! When Graph 4 is active, all the following commands work in Graph 4! Obviously there is something wrong! But I donīt know what!
Can anyone help me please? Thanks in advance

Steffen
5   L A T E S T    R E P L I E S    (Newest First)
Baertram0815 Posted - 02/16/2006 : 11:48:24 AM
Hi again,

it seems like this works:

for
(jj=2;jj<=20;jj++)
{
for
(ii = 1;ii<=19;ii ++)
{
%A = Data1!wks.col$(jj).name$;
%A = Spalte_%A;
Data1!wks.col$(jj).label$ = %A;
pe_mkdir(%A);
pe_move(%A,"/Filename");
window -a Graph$(ii);
page.active = 1;
layer -c;
layer -e %Z;
layer -i200 %(Data1,jj);
layer.x.rescale = 1;
layer.y.rescaleMargin = 2;
layer -a;
window -d;
window -r Graph20 %A_$(ii);
%B = /Filename/%A;
pe_move(%A_$(ii),%B);
};
};

So long
Steffen
Baertram0815 Posted - 02/16/2006 : 11:08:06 AM
By the way:

Is there any possibility to "increase" a character? I would like to automatically rename the columns from "column_B" to "column_X".
It should work like this:

for
(ii=2;ii<=24;ii++)
{
%A= column_/**Now here should be a term that makes it possible to convert the number ii (for instance "2") to the ii th (for instance "second") character of the alphabet (namely "B")/*
data1!wks.col$(ii).label$ = %A
}

Any ideas?

Thanks in advance
Steffen
Baertram0815 Posted - 02/16/2006 : 08:37:34 AM
Good Morning Mike,

you absolutely solved my probs. Thanks a lot!

Steffen
Mike Buess Posted - 02/15/2006 : 09:27:09 AM
Hi Steffen,

Easiest to start with your last question.

>> It's not necessary to write the loop script in one line. Ending a line with semicolon and pressing Enter (or Ctrl+Enter) should not generate a command error. Line is executed when you press Enter without the semicolon.

>> As far as plotting columns D and later, consider replacing the wksName_colName dataset notation with %(wksName,colNumber). For example,...

for(jj=3;jj<10;jj++) {
layer -i200 %(Data1,jj);
};

>> You need help from Origin C to work with folders. The following Origin 7.5 functions (pe_mkdir and pe_move) work in 7.0 SR4. Add them to your workspace as described here...
http://www.nmrtools.com/labtalk/tryOC.html

// functions start here
/**
Create a new directory
Example:
pe_mkdir("myDir") //a new directory named myDir is created
Parameters:
subfolderName = name of the new folder to be created; if the name already exists, it will add number after name.
Return:
SeeAlso:

*/
void pe_mkdir(string subfolderName)
{
Folder fld = Project.ActiveFolder();
Folder subfld = fld.AddSubfolder(subfolderName);
if( !subfld.IsValid() )
{
printf("Error!!! Can't Create new subfolder %s !\n", subfolderName);
}
}


/**
Move a page or subfolder in current folder to another folder.
Example:
pe_move("myPage", "../myDir") //move myPage to the directory myDir
Parameters:
strItemName = name of the existing page
strPathName = path of the location where the page should be moved to
Return:
SeeAlso:
*/
void pe_move(string strItemName, string strPathName)
{
Folder fld = Project.ActiveFolder();
if( !fld.Move(strItemName, strPathName) )
{
printf( " Error!!! Can't move %s to %s !", strItemName, strPathName );
}
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 02/15/2006 10:05:07 AM
Baertram0815 Posted - 02/15/2006 : 08:40:31 AM
Hi again,

I went through the problem again and found out the following command works:

for (ii = 1; ii <= 18; ii ++)
{
window -a Graph$(ii);
page.active = 1;
layer -c;
layer -e %Z;
layer -i200 DATA1_d;
}

With this command I only have to replace DATA1_d to e, f, and so on and then save the file. I thought about to autorescale the graph with the following command.

layer.x.rescale = 1;layer.y.rescaleMargin = 2;layer -a;

Without the for-loop this works fine. Within the loop it doesnīt work. Also the problem with shifting the graphs into another folder has not yet been solved.

Another question: When writing the for-loop in the script window it only works when writing it in a line. Trying to structurate the loop gives back the message #command error. Isnßt it possible to structurate the commands in order to have a better understanding of what is going on in the command?

So long
Steffen

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000