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
 Loop over columns
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

zevgdimi

4 Posts

Posted - 06/25/2015 :  3:00:05 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

I am new to Labtalk so I have some problems that are probably quite easy to solve. I would like to write a short script to rename the columns of imported asciis. So far I achieved to delete unnecessary columns and plot all data.
Now to my actual problem:
I have a dataset containing 17 columns. In the first column I have data of a voltage increment which serve as x-values for all other columns and which I renamed per script. Now I would like to rename all subsequent columns with "Pix #" where # is an integer increment from 1 to 16.
I did an internet research and found out that I have to use the wks.col command in combination with a loop but I could figure out a working solution. I achieved to rename all columns manually which works fine but I am sure there is a better solution.

I hope you understand my problem and can help me.

Thanks a lot.

cdrozdowski111

USA
247 Posts

Posted - 06/25/2015 :  3:35:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Zevgdimi,

Try this to rename columns in the active worksheet starting with column 2 and going to last columns:

loop(nn, 2, wks.ncols) {
	range rr = wcol(nn);
	rr.name$ = "Pix$(nn)"; // Column short name
	rr.label$ = "Pix $(nn)"; // column long name
}


Thanks,
Chris Drozdowski
Originlab Technical Support
Go to Top of Page

zevgdimi

4 Posts

Posted - 06/25/2015 :  3:55:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for you message.
Unfortunately, your solution is only partially working. The longnames are changed, however not as "Pix #" but rather as "Pix$(nn)". That means that the whole expression on the right side is added as string. Is there a possibility to convert the expression to numeric type?

Thanks again.
Go to Top of Page

cdrozdowski111

USA
247 Posts

Posted - 06/26/2015 :  09:18:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
zevgdimi,

What version of Origin are you using? The script I posted doesn't work in Origin before version 8. I've tested it on version 8 and 2015.

Also I made a small error in my script. This is the corrected one:

loop(nn, 2, wks.ncols) {
	range rr = wcol(nn);
	rr.name$ = "Pix$(nn-1)"; // Column short name
	rr.label$ = "Pix $(nn-1)"; // column long name
}

Edited by - cdrozdowski111 on 06/26/2015 09:22:37 AM
Go to Top of Page

zevgdimi

4 Posts

Posted - 06/26/2015 :  12:45:15 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

I am using Origin 9.1. Your solution is working fine, thank you. Unfortunately I had a little typo (inserted a space between Pix$ and (nn-1) so it wasn`t right.

Again thanks a lot.

Edited by - zevgdimi on 06/26/2015 12:54:53 PM
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