The Origin Forum
File Exchange
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
 Origin Forum
 How to get selected data from wks in Labtalk?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

newuser_ca

66 Posts

Posted - 05/22/2012 :  3:41:11 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 8.6 in Windows 7.

Hi,

I have a worksheet and a button as below.
How can I get the selected cell information in Labtalk? eg. I selected "T023325", "T023327", "T023328". I want to use the selected strings as inputs to my Origin C function.
Thanks.

easwar

USA
1853 Posts

Posted - 05/22/2012 :  5:42:23 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can use the X-function named get_wks_sel. It looks like this did not make it into the help file in 8.6, but you can go to the script window and type:
get_wks_sel -h
and press Enter to get the information on how to use it

Easwar
OriginLab
Go to Top of Page

newuser_ca

66 Posts

Posted - 05/23/2012 :  11:12:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks a lot.
But how can I get the outputs?
I have the following codes:


But when I click the button, I didn't get anything:


If I type "get_wks_sel str:=selection" in command window, I can get:

get_wks_sel.str = [import]Sheet1!1[1:1]|[import]Sheet1!1[2:2]|[import]Sheet1!1[4:4]
Go to Top of Page

newuser_ca

66 Posts

Posted - 05/23/2012 :  1:46:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I think I know how to get it now.
the scripts should be:

get_wks_sel str:=selection1$;
type -b "str is %(selection1$)";

Thanks for the help.
Go to Top of Page

newuser_ca

66 Posts

Posted - 05/23/2012 :  2:30:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I got another problem now.
It is very interesting.

If I select row 1,2,4 (hold ctrl key), I got:
get_wks_sel.str = [import]Sheet1!1[1:1]|[import]Sheet1!1[2:2]|[import]Sheet1!1[4:4]
--- This is ok.

But if I select row 1 and hold shift key and click row 4 (that means I select row 1-4), then click row 3 to deselect, I got:
get_wks_sel.str = [import]Sheet1!1[1:4]|[import]Sheet1!1[3:3]

looks like deselect is not working here.

if I select row 1, hold ctrl key, then select row 3, then row 1, then row 3, I got:
get_wks_sel.str = [import]Sheet1!1[1:1]|[import]Sheet1!1[3:3]|[import]Sheet1!1[1:1]|[import]Sheet1!1[3:3]

It seems to me that whenever I click the cell, I get one entry in the string.

My questions are:
1. Is it able to deselect a cell?
2. How to get exact information from the selected cells without repeated information?

Thanks.
Go to Top of Page

Hideo Fujii

USA
977 Posts

Posted - 05/23/2012 :  4:46:56 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi newuser_ca、

Yes, deselection is not working (unless the selection is column-based), and thanks for letting us the problem. I will report this bug to our developers. We're sorry for the inconvenience.

--Hideo Fujii
OriginLab
Go to Top of Page

newuser_ca

66 Posts

Posted - 05/25/2012 :  11:35:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks.
When can this be fixed? Will you have a new patch available online?
Go to Top of Page

greg

USA
1233 Posts

Posted - 05/25/2012 :  4:55:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This is not a bug; it's by design. There is no deselect and it's unlikely we will add it.
Since plotting and analysis can both handle multiple ranges, it is a feature to be able to accumulate multiple selections where there may be overlap of selections.
If you made a mistake in your selection, just click outside and start again.

To see this in action:

Select rows 1 to 3
Hold down Ctrl key and select 4 to 6
Hold down Ctrl key and select 7 to 9
Select string is now [Book1]Sheet1![1:3]|[Book1]Sheet1![4:6]|[Book1]Sheet1![7:9]
Choose Plot : Line
A new feature since Origin 8 is that the same dataset (different ranges) can be plotted multiple times in one layer. In this case grouping of these subranges lead to group coloring.
But note the discontinuities in the graph.

Now clear your selection and select
Rows 1 to 3
Hold down Ctrl key and select 3 to 6
Hold down Ctrl key and select 6 to 9
Select string is now [Book1]Sheet1![1:3]|[Book1]Sheet1![3:6]|[Book1]Sheet1![6:9]
Plot this and you get a continuous line.

Note that once you have made this complex selection, there is no visual way to determine what has been selected let alone what has been selected multiple times. Any system we devised that would actually indicate multiple, overlapped selections would be too complicated to be useful and would be doubly so if we we threw deselection into the mix.
Go to Top of Page

newuser_ca

66 Posts

Posted - 05/29/2012 :  1:51:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the explanation.

Go to Top of Page

BPrzybyla

Germany
6 Posts

Posted - 03/05/2014 :  05:06:13 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OriginPro 8.1, Windows 7 64bit

Hi,

any chance to have this function for 8.1?

Best regards,

B. Przybyla
Go to Top of Page

BPrzybyla

Germany
6 Posts

Posted - 03/06/2014 :  02:36:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi again! I found a quick workaround for my previous problem. Not very neat but it works... surprisingly...


void wks_get_datarange_selection_ex()
{
	//Make sure the active worksheet has existed
	Worksheet wks = Project.ActiveLayer();
    if(!wks)
    {
    	printf("Error. Please active worksheet before running!");
    	return;
    }
 
 	vector<int> vR1, vC1, vR2, vC2;
 	
    int iRegions = wks.GetSelectedRange(vR1, vC1, vR2, vC2);	//get the number of regions
 
    if( 0 == iRegions )
    {
    	printf("No range selected in the active worksheet %s!", wks.GetName());
    	return;
    }
    
    for(int ii = 0 ; ii < iRegions ; ii++)
    {
        printf("Region %u : R%d C%d : R%d C%d\n", ii, vR1[ii], vC1[ii], vR2[ii], vC2[ii]);
    }
    
         WorksheetPage wp;
	wp.Create(NULL, CREATE_VISIBLE);
	int nNumRows = iRegions;
	int nNumCols = 4;
	Worksheet wksn = Project.ActiveLayer();
	wksn.SetSize(nNumRows, nNumCols);
	Dataset dsB;
	dsB.Attach(wksn,0);
	dsB = vR1;
	dsB.Attach(wksn,1);
	dsB = vC1;
	dsB.Attach(wksn,2);
	dsB = vR2;
	dsB.Attach(wksn,3);
	dsB = vC2;
}
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 © 2008 Originlab Corporation Go To Top Of Page
Snitz Forums 2000