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
 From many wks to just one
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

senigalliese

Australia
Posts

Posted - 11/19/2005 :  07:47:06 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: XP

Dear members of the forum, here I am again for a piece of information/help. I have many worksheets with three columns of the type XYZ. My final target is to plot a contour plot put of a matrix obtained from a single worksheet that generate manually (so far) simply copying and pasting the three XYZ columns of each worksheet to the single one that I will convert in matrix. The reason is that every single woksheet has a different value of Z.
How can I perform this action with labtalk?

Mike Buess

USA
3037 Posts

Posted - 11/19/2005 :  11:46:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I'm not sure if you want to paste as new columns or new rows so here are both methods.

1. Select View > Windows > Windows in Active Folder.
2. Move all worksheets that you want to combine to a new project folder.
3. Select the new folder in Project Explorer or from the Window > Folders submenu.
4. Run one of these scripts...

# Paste as new rows
win -t D; // create new wks
%W=%H; // save name
wks.addCol(); // add column
wks.col3.type=6; // set type to Z
# operate on all worksheets in active folder
doc -ef W {
if("%W"!="%H") {
loop (ii,1,3) {copy -a %(%H,ii) %(%W,ii)}; // append columns
};
};

# Paste as new columns
%I=%H;
work -d;
%W=%H;
doc -ef W {
if("%W"!="%H" && "%I"!="%H") {
%W!wks.addCol();
%W!wks.col$(%W!wks.ncols).type = 4;
%(%W,%W!wks.ncols) = %(%H,1);
%W!wks.addCol();
%(%W,%W!wks.ncols) = %(%H,2);
%W!wks.addCol();
%W!wks.col$(%W!wks.ncols).type = 6;
%(%W,%W!wks.ncols) = %(%H,3);
};
};

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/19/2005 12:19:19 PM
Go to Top of Page

senigalliese

Australia
Posts

Posted - 11/20/2005 :  08:47:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much Mike, once again.
Your routine works well, and as matter of fact I had to add as new rows. I wonder if I can automate my Lab Talk routine even further creating folders and then moving wks named "Loop$(i)$(j)" to this new folder and make it active as well.

Many thanks for your time, have a nice week end.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/20/2005 :  10:31:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Well, you can use the Extended LabTalk commands...

pe_mkdir fldName; // create fldName folder
pe_move wksName fldName; // move wksName to fldName
pe_cd fldName; // go to fldName

Your wksNames are easy to generate so you can put the pe_move command in a loop. However, it's just as easy to combine the worksheets directly in a similar loop. (I suggested the folder method only to avoid the naming issue.)

i1 = 1; // first i value
i2 = 100; // last i value
ii = 1; // i increment
j1 = 1; // first j value
j2 = 100; // last j value
jj = 1; // j increment
win -t D; // create new wks
wks.addCol(); // add column
wks.col3.type=6; // set type to Z
for(i=i1;i<=i2;i+=ii) {
for(j=j1;j<=j2;j+=jj) {
%A=Loop$(i)$(j);
loop (k,1,3) {copy -a %(%A,k) %(%H,k)};
};
};

...If the row order in the combined wks is important the next script sorts the entire wks using col A and B as primary and secondary sequences.

sort.wksName$=%H;
sort.c1=0; // all columns
sort.r1=1; // start row 1
sort.r2=wks.maxrows; // stop last row
sort.cName1$=A: A; // primary sort: ascending order in col A
sort.cName2$=A: B; // secondary sort: ascending order in col B
sort.wks();

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/20/2005 10:50:00 AM

Edited by - Mike Buess on 11/20/2005 11:05:57 AM
Go to Top of Page

senigalliese

Australia
Posts

Posted - 11/22/2005 :  06:04:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike, your help is really appreciated. I am trying to use the pe_move command in a llop in order to move all my Loop$(i)$(j) wks inot another folder but when I use pe_move Loop$(i)$(j) fldname I always get an error message that says Error!!! Can't move Loop$(i)$(j) to fldname!
There must be a way to pass the name of the numbered wks to the pe_move command, but I am confused and do not know how to solve this problem.

Thanks Mike again.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 11/22/2005 :  07:56:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This will work..

%F=NewFld; // new folder name
i1 = 1; // first i value
i2 = 100; // last i value
ii = 1; // i increment
j1 = 1; // first j value
j2 = 100; // last j value
jj = 1; // j increment
pe_mkdir %F
for(i=i1;i<=i2;i+=ii) {
for(j=j1;j<=j2;j+=jj) {
%A=Loop$(i)$(j);
pe_move %A %F;
};
};
pe_cd %F;

Mike Buess
Origin WebRing Member
Go to Top of Page

senigalliese

Australia
Posts

Posted - 11/22/2005 :  10:35:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It does indeed!

Your help is most valuable, thanks Mike!
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