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
 Origin Forum
 LookUp / Cell / Set Value Help please
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

khblue

United Kingdom
5 Posts

Posted - 12/07/2018 :  11:55:30 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Blauser

USA
1 Posts

Posted - 12/10/2018 :  07:47:12 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Are you not supposed to assign a value to a range? Why's that?
Go to Top of Page

YimingChen

1684 Posts

Posted - 12/10/2018 :  2:43:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here col(B) is a dataset, only array can be assigned to dataset, setting a value to dataset is syntactically not valid.

James
Go to Top of Page

khblue

United Kingdom
5 Posts

Posted - 12/11/2018 :  04:55:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks I'll give it a go
Go to Top of Page

khblue

United Kingdom
5 Posts

Posted - 12/11/2018 :  05:19:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

YimingChen

1684 Posts

Posted - 12/11/2018 :  09:20:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

khblue

United Kingdom
5 Posts

Posted - 12/11/2018 :  10:20:40 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
--------------------------------
Go to Top of Page

YimingChen

1684 Posts

Posted - 12/11/2018 :  10:56:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Please check this method:


Thanks,
James
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