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
 All Forums
 Origin Forum
 Origin Forum
 Using cell values in a function/script

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
DerekK Posted - 03/02/2016 : 3:58:32 PM
I am not an expert yet on scripting, but I would like to try this...

I am using ReduceDup to create a new column. To change the range of x values for the input, I need to go into Change Parameters and modify manually.
Is there a way to get these values from other cells?

I tried to use Set Column Values to populate a column this way. So I did the generate script and got this...
reducedup -r 1 iy:=Data!(W1"T bin",L1"delta h")[x15:25] method:=sum;

I want to put this in the script before function. How do I make the "[x15:25]" read the 15 and 25 from cells in the worksheet?

Thanks, Derek

Origin Ver. and Service Release (Select Help-->About Origin): 2015sr1
Operating System: win7
11   L A T E S T    R E P L I E S    (Newest First)
cpyang Posted - 10/01/2020 : 8:13:01 PM
Your book name might be an issue, but try this formula


=%([A1$],3,0)

Assuming the book name is in A1 and you want to get the last row value of the 3rd column.

The row index = 0 to get the last cell value was introduced in 2020b. ORG-21624-S2.

We will improve this in 2021, so you can do

=[A1$]1!C[0]



CP
DanielSchumann Posted - 10/01/2020 : 09:08:00 AM
Thanks. I submitted the project to tech@originlab.com
YimingChen Posted - 10/01/2020 : 08:30:21 AM
Please attach your two worksheets or send the project file to <tech@originlab.com> that we can check further.

James
DanielSchumann Posted - 10/01/2020 : 03:14:11 AM
Thanks James for this quick answer.
Unfortunately, it doesn't work. Error Message: unknown function.

Do you have any other idea?
YimingChen Posted - 09/30/2020 : 12:12:39 PM
Try the script below, it retrieves the last value of col(3) of workbook saved in A1.
=%([%(A1$)]1, 3, [%(A1$)]!wks.col3.nrows)




James
DanielSchumann Posted - 09/30/2020 : 05:16:17 AM
Hello,
I hope this is the right topic. But at least it is the most suitable for my problem.
I want to refer a bookname from a cell value in a formula.
Example:
In Cell A1 the bookname is written as string: "V1-1"
In Cell B1 is a formula which revers to another book with name in cell A1: =lastpoint([V1-1]1!L)

how do I refer cell A1 in the formula? I tried different ways, no one functioned.
Can you help me?

Thanks, Daniel
cpyang Posted - 03/04/2016 : 9:05:26 PM
We should add another string register to get the parent book name, but in the mean time, you can use

%(%(1Y,@W),@WL,B[1], W) 

Which will translate into %(Book14),@WL,B[1], W)

or to be more precise

%([%(1Y,@W)]%(1Y,@WS),@WL,B[1], W) 

In the [book]sheet notation.
The above is to find the sheet that hold the 1st data plot's Y column.

See
http://www.originlab.com/doc/LabTalk/ref/Legend-Substitution-Notation#List_of_.40Options

CP
DerekK Posted - 03/04/2016 : 09:40:16 AM
Hi Sean
Thanks for the response... As you showed, I used %H in place of "Book14", but that does not work (just the code of the link is shown). The linked value only displays if the "Book 14" is there.
Just to be clear, I am adding text on a graph. And I have made the graph as a sheet in the same workbook as the data sheet "Data".
When I type %H=; into the script window, I get "Graph4" which is the name of the graph sheet, not the workbook. I tried the other string registers and the closest I got was %E --> "[Book14]Graph4". I couldn't find one that returns just the "Book14".
- Derek
SeanMao Posted - 03/03/2016 : 9:07:19 PM
Hi,

col("longname") is safer in case of column index change.

To refer to current workbook, you can use a built-in string register %H.

In your case, it would be:

Range = %([%H]Data,@WL,Y1[1], W) to %([%H]Data,@WL,Y1[2], W)

Please see the follow page for reference about other system string registers:

http://www.originlab.com/doc/LabTalk/guide/String-registers#String_Registers_as_System_VariablesSystem_VariableString_Register.2C_System_VariableSystem_Variable.2C_String_Regester

Regards!

Sean
DerekK Posted - 03/03/2016 : 12:34:18 PM
Thanks, that works. Two questions...
I assume that column references in scripts are static... So, if I change the column order then the wcol() could refer to the wrong column. So is it safer to use the Col(A) or Col("XXXXX") method instead?

Also, I have pasted a link into a text field on a graph in a worksheet. When I save the worksheet as a template, it keeps the reference to the old sheet name (Book14) in the link. How do I make it refer to the current sheet name instead.

Range = %([Book14]Data,@WL,Y1[1], W) to %([Book14]Data,@WL,Y1[2], W)
Echo_Chu Posted - 03/03/2016 : 05:04:24 AM
Hi, Derek

Please look at the image below as an example.
Column A and B are source data with duplicate X value. The X range is put in column C, starting as 5 and end as 12.

Then I set values of column D as in the dialog. And below are scripts which put in the Before Script Panel. the scripts read cell values to be r1 and r2 then use it in the reduceup function. Output the result to the 5th and 6th column.
Please note that in dialog I set column D = column C, which will trigger the recalculation if values of column C changes.

double  r1 = wcol(3)[1:1]; //1st row of col(c)
double  r2 = wcol(3)[2:2]; //2nd row of col(c)
reducedup iy:=1!(wcol(1),wcol(2))[x$(r1):$(r2)] oy:=(wcol(5), wcol(6));



Echo
OriginLab Corp

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000