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
 Loop over columns

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
zevgdimi Posted - 06/25/2015 : 3:00:05 PM
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.
4   L A T E S T    R E P L I E S    (Newest First)
zevgdimi Posted - 06/26/2015 : 12:45:15 PM
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.
cdrozdowski111 Posted - 06/26/2015 : 09:18:27 AM
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
}
zevgdimi Posted - 06/25/2015 : 3:55:41 PM
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.
cdrozdowski111 Posted - 06/25/2015 : 3:35:01 PM
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

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