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
 read content of selected cells
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

paola.bolognesi

4 Posts

Posted - 01/27/2011 :  11:54:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. 7.5 SR7
Operating System: windows7

Hi,
I would like to execute a LabTalk script on a range of worksheet data selected by highlighting the data from the worksheet (with mouse).
For example, out of a huge worksheet, I need to select few rows of two adjacent columns, taking the weigthed average of data in the second selected column and using data in the first selected column as weigth.

However, I cannot find the labtalk command that returns the content of cells selected in such way.

Could you please help me with that ?

Many thanks
Paola

greg

USA
1378 Posts

Posted - 02/02/2011 :  3:33:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The object properties you are looking for are
wks.c1 First column number of selected range
wks.c2 Last column number of selected range
wks.r1 First row number of selected range
wks.r2 Last row number of selected range

Here is an example that simply copies the data to new columns:

// BEGIN SCRIPT
// Loop over all selected columns
loop(iCol,wks.c1,wks.c2)
{
wks.addcol(Copy);
// and loop over all selected rows
for(RdRow=wks.r1,WrRow=1;RdRow<=wks.r2;RdRow++,WrRow++)
{
cell(WrRow,wks.ncols) = cell(RdRow,iCol);
}
}
// END SCRIPT
Go to Top of Page

zumix

Spain
5 Posts

Posted - 10/19/2012 :  04:53:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi guys. I'm using ver.8.1
I've come to this topic looking for how to loop over a selected range of worksheets inside a book. I select a few with crtl+mouse and then i want to apply a script to them. Is there anything as wks.c1 c2... for selected wks?
Cheers
Go to Top of Page

greg

USA
1378 Posts

Posted - 10/23/2012 :  09:26:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There is an XFunction useful for getting complex range selections, unfortunately you don't have it in 8.1 and therefore would have to use OriginC for such selections.

Here is an example of the new XFunction:
get_wks_sel str:=str sep:=| wks:=[Book1]Sheet1;
str$ =;
[Book1]Sheet1!2[1:6]|[Book1]Sheet1!3[6:10]|[Book1]Sheet1!4[10:14]
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