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
 LabTalk and Set Column Values

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
bur2000 Posted - 12/11/2013 : 08:59:19 AM
Origin Ver. and Service Release (Select Help-->About Origin): 8.6

I want to add the values of three columns, then round the result to 3 digits and write it to a fourth column.

I was trying this script in Set Column Values...

double sum = Col(A)+Col(B)+Col(C);
double roundSum = Round(sum,3);

Unfortunately this enters the sum of the first rows in all rows of Col(D). I tried Col(A)[i], but that doesn't work at all.

Is it possible to address the specific row in a script?
4   L A T E S T    R E P L I E S    (Newest First)
lkb0221 Posted - 12/11/2013 : 3:21:01 PM
In Set Values dialog, because your input is a dataset, Col(A)+Col(B)+Col(C), so the output will also be a dataset. So it will only run once and give all the values.

The data type of range is like a pointer, it just allows you to access your data easily in a standard way. But itself does not contain any data.
bur2000 Posted - 12/11/2013 : 10:46:38 AM
Thanks for your replies.

So when using "Set Column values" the script is only run once and then the formula box is applied to each row? I thought the script was run for each row.

Dataset also works well, but I don't understand why range can't be used in this case. I tried range and it doesn't sum the values but simply uses the values of the first column.

For example
range sum = Col(A)+Col(B);

Fills the column with the values of A.
lkb0221 Posted - 12/11/2013 : 10:32:18 AM
Hi, Bur

That is because you defined the variable "sum" and "roundsum" to be double, which can only keep one numeric data.

I guess you want to let each row in col(D) has the rounded sum of column A, B and C correspondingly.

To do this, just change all the "double" to "dataset".

Zheng
OriginLab
snowli Posted - 12/11/2013 : 10:29:51 AM
Open Set Column Values dialog of the 4th column.

Enter
round(col(A)+col(B)+col(C),3)

in the formula box.

It will add each row and round to 3 digits.


You defined double for sum and roundsum so they only return one value. You don't have to use the script before fomula in such case.

Thanks, Snow
OriginLab Corp.

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