Author |
Topic  |
|
khblue
United Kingdom
5 Posts |
Posted - 12/07/2018 : 11:55:30 AM
|
Origin Ver. 2018b and Service Release b9.5.5.409 educational Operating System: Win 7
I'm new to LabTalk and only recently back using Origin. I'm not sure what I'm suggesting is an efficient solution, but hopefully my inept attempts will help understand the problem. Please suggest a best method or correct my syntax/coding. Many thanks.
PROBLEM: I want to use the VALUE from the current book and sheet, Col A, row [i] as the ROW Number for selecting the value from a different book and sheet, in column 1, and putting it in Col B of my current sheet.
MY FIRST ATTEMPTED SOLUTION: Col(B)=cell://[Data1]Sheet1!A[cell://A[i]]
MY SECOND ATTEMPTED SOLUTION: Before formula script: double HERE = [Data2]Sheet1!Cell(i,1)
Col(B) = [Data1]Sheet1!Cell(HERE,1) |
Edited by - khblue on 12/07/2018 12:10:20 PM |
|
YimingChen
1684 Posts |
Posted - 12/07/2018 : 1:48:44 PM
|
Hi,
I think the reason is that you try to assign a value to a range. You can try:
col(B)[1] = [Data1]Sheet1!Cell(HERE,1);
Thanks, James |
 |
|
Blauser
USA
1 Posts |
Posted - 12/10/2018 : 07:47:12 AM
|
Are you not supposed to assign a value to a range? Why's that? |
 |
|
YimingChen
1684 Posts |
Posted - 12/10/2018 : 2:43:40 PM
|
Here col(B) is a dataset, only array can be assigned to dataset, setting a value to dataset is syntactically not valid.
James |
 |
|
khblue
United Kingdom
5 Posts |
Posted - 12/11/2018 : 04:55:40 AM
|
thanks I'll give it a go |
 |
|
khblue
United Kingdom
5 Posts |
Posted - 12/11/2018 : 05:19:21 AM
|
Hmmm, I'm not getting further with that.
In the dialogue box I have a 'Before Formula Script' and 'Col (B) =' box. Perhaps I need to create an array and populate it using the 'Before Formula Script' box then set Col (B) = MyArray.
Saying that I have no idea about how to do that, it's been about 10 years since I did any coding and that was C/C++ !!
Any more specific help would be really valued, thanks. |
 |
|
YimingChen
1684 Posts |
Posted - 12/11/2018 : 09:20:47 AM
|
Hi,
Sorry for the confusion. In Set Column Values dialog box, Before Formula Scripts box accepts LabTalk script, while Col(B)= box is accepting expression in which case you can put in an expression which returns a number. So your second method should work. Please see attached pic:

Hope this answers your question, thank you.
James |
 |
|
khblue
United Kingdom
5 Posts |
Posted - 12/11/2018 : 10:20:40 AM
|
Thanks James. I ended up here, which works but is probably inefficient:
----------------------------------------- Dataset TROUGHS = {1:1:200}; double value = 0; int line = 1;
For (n=1;n<200;n++) { // get the x-value for the next trough line = [Data2]Sheet1!Cell(n,1); // use the x-value to look up the y-value // of the peak in the original data set value = [Data1]Sheet1!Cell(line,2); // put that value in the temporary data set TROUGHS[n] = value; }
// Assign column values from the temporary data set Col(B)=TROUGHS -------------------------------- |
 |
|
YimingChen
1684 Posts |
Posted - 12/11/2018 : 10:56:08 AM
|
Please check this method:

Thanks, James |
 |
|
|
Topic  |
|