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
 Replacing data in several layers
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Baertram0815

Germany
Posts

Posted - 02/15/2006 :  05:32:39 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Baertram0815

Germany
Posts

Posted - 02/15/2006 :  08:40:31 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 02/15/2006 :  09:27:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Baertram0815

Germany
Posts

Posted - 02/16/2006 :  08:37:34 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Good Morning Mike,

you absolutely solved my probs. Thanks a lot!

Steffen
Go to Top of Page

Baertram0815

Germany
Posts

Posted - 02/16/2006 :  11:08:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Baertram0815

Germany
Posts

Posted - 02/16/2006 :  11:48:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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