T O P I C R E V I E W |
newuser_ca |
Posted - 05/22/2012 : 3:41:11 PM 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.
 |
11 L A T E S T R E P L I E S (Newest First) |
AKazak |
Posted - 07/05/2022 : 04:17:03 AM OriginPro 2022b (64-bit) SR1 9.9.5.167 Windows 7 Pro SP1 x64
Greetings!
Is there a LT function to get selected cells as a range object?
--- Andrey |
BPrzybyla |
Posted - 03/06/2014 : 02:36:32 AM 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;
}
|
BPrzybyla |
Posted - 03/05/2014 : 05:06:13 AM OriginPro 8.1, Windows 7 64bit
Hi,
any chance to have this function for 8.1?
Best regards,
B. Przybyla |
newuser_ca |
Posted - 05/29/2012 : 1:51:29 PM Thanks for the explanation.
|
greg |
Posted - 05/25/2012 : 4:55:13 PM 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. |
newuser_ca |
Posted - 05/25/2012 : 11:35:45 AM Thanks. When can this be fixed? Will you have a new patch available online? |
Hideo Fujii |
Posted - 05/23/2012 : 4:46:56 PM Hi newuser_caA
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
|
newuser_ca |
Posted - 05/23/2012 : 2:30:25 PM 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. |
newuser_ca |
Posted - 05/23/2012 : 1:46:44 PM 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. |
newuser_ca |
Posted - 05/23/2012 : 11:12:21 AM 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]
|
easwar |
Posted - 05/22/2012 : 5:42:23 PM 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 |
|
|