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
 Apply script to selected 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

PaulJohns

5 Posts

Posted - 11/03/2017 :  5:04:29 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I have worksheets that consist of columns of information that I want to perform a function on. The columns vary from file to file, so I would just like to be able to select (with the mouse) the columns that the function should be applied to and then run my LabTalk script on only those (potentially non-adjacent) columns. Is there a way to do this?

nick_n

Finland
125 Posts

Posted - 11/04/2017 :  7:00:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

- wks.c1=; returns index of selected column (or leftmost if there are several selected cols).

- wks.isColSel([colNum]) if you need to know all selected columns (using looping over all columns).

see more at http://www.originlab.com/doc/LabTalk/ref/Wks-obj
Best,



Nikolay
Go to Top of Page

PaulJohns

5 Posts

Posted - 11/06/2017 :  12:19:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks. That seems to give me a start. This should be very simple, but I can't seem to get my code to run with any regularity. This is what I have:

[Main]
int NumColumns = wks.ncols;
for(ii=1; ii<=$(NumColumns); ii++;){
	if(wks.isColSel([ii])){
		col($(ii))=1/(col($(ii))*0.000000001/0.01);
	}
}


This code is stored in a file in my user path called ntol.ogs If I go to the Script Window and try to run it, I can get it to work once by typing in ntol; or run.section(ntol); or some other combinations, but then it won't run again, for example if I move to a different sheet, or even if I just select a different column in the same sheet. How do I get it to run again?
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 11/06/2017 :  1:21:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
Unfortunately, I cannot reproduce that issue.
Try to change your loop: for(ii=1; ii<=NumColumns; ii++) , no needs to use $ substitution
and wks.isColSel(ii) without square brackets.
Best,

Nikolay
Go to Top of Page

nick_n

Finland
125 Posts

Posted - 11/06/2017 :  1:31:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You do not have to use [Main] in .ogs
If you use that run.section(ntol, main);
BR, Nikolay

Nikolay
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