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
 creating multiple workbooks inside a cycle if
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Iole

United Kingdom
4 Posts

Posted - 04/30/2015 :  11:19:43 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Dear all,

I am new to Origin LabTalk and I need some help.

I have managed to separate a long column of data into multiple columns on which I can work separately, by using a cycle "for" and the conditioning "if".

What I would like to do is to save each column into a new workBook, that is generated automatically as the cycle is run trough. Any suggestion on how to do that?

Thank you very much in advance,
I.

ziffirina

JRoby

USA
6 Posts

Posted - 04/30/2015 :  4:40:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Doing this within the loop may be difficult since you can only run the code when an extracted column is complete.
Perhaps a repeated use of the wxt function which can accept conditions and create a new workbook may be a better approach.
Once you have a column to copy to a new book (here the column number is stored in the 'icol' variable), you could use this code:

range raC = $(iCol); // iCol is the column to copy
%M = %H; // Remember this workbook
newbook; // Create a new book
range raD = 1; // or whatever target column you want
win -a %M; // Go back to original workbook
copy raC raD; // Copy column to new book column

The last two line are interchangeable.
Go to Top of Page

Iole

United Kingdom
4 Posts

Posted - 05/01/2015 :  07:41:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much, that worked very well, I have used it to copy and locate more than one column. Do you think is also possible to do operation between them inside the new workbook created? For example say I have copied two column in position number 1 and 2, can I have the sum of the two in column 4, for each new book created?

Thank you very much for your help in advance,

ziffirina

Edited by - Iole on 05/01/2015 09:57:15 AM
Go to Top of Page

JRoby

USA
6 Posts

Posted - 05/01/2015 :  4:22:03 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Before you switch back to the 'main' workbook (win -a %M;), you can execute:
col(4) = col(1) + col(2);

Alternatively, if you save a workbook where column 4 has a Set Column Values expression of:
col(1) + col(2);
set to Auto execute, your newbook command can be told to load that template and the sum will occur automatically:
newbook template:=MySUMWkBk; // MySUMWkBk.OTW is the template
Go to Top of Page

Iole

United Kingdom
4 Posts

Posted - 05/05/2015 :  09:24:55 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you very much!!

I have one more question. I inserted in the cycle if the command to create a graph so that all the columns I have separated will be plotted on the same graph. Is it possible to give an instruction so that they will be part of the same group and possibly each xy set of data will be represented by same symbol (preferably small empty circle) but different color?

Thanks again


Edited by - Iole on 05/05/2015 09:29:16 AM
Go to Top of Page

lkb0221

China
497 Posts

Posted - 05/18/2015 :  12:14:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can customize the plot each time you added to the graph.
Please see the following Set cmd:
http://www.originlab.com/doc/LabTalk/ref/Set-cmd
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