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 for Programming
 LabTalk Forum
 how to store sum of column in variable?

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
Andreas_D Posted - 06/02/2010 : 10:42:49 AM
Origin Ver. and Service Release (Select Help-->About Origin): 7.5878
Operating System:WinXP Pro SP3

Hi again,

I am now trying in Origin 7.5 to store the sum of several columns into a variable like so:

sum(%e_l);
sumTx=$(sum.total);
sum(%e_m);
SumTy=$(sum.total);
sum(%e_n);
SumTz=$(sum.total);

This doesn't work when included in the ogs-script, but when I enter the lines manually in the script window it works OK.

How can I resolve this?

Your help is much appreciated,
Andreas
2   L A T E S T    R E P L I E S    (Newest First)
Andreas_D Posted - 06/08/2010 : 06:08:57 AM
Hi Pen,

thanks for your answer.
I think it has to do with the timing of the column calculations. I saved the calculations on a few columns in a worksheet template I am using during the script, and the sum command uses these columns. So by the time the sum command is due, the columns have not yet been calculated so that is probably why the variables ontain no data.
I tried putting in:

second -p 10;

but still the columns are calculated too late for the sum command.

I worked my way around this now, by defining the calculations of the necessary columns in script rather than in the worksheet template by adding:

col(l)=col(b)(col(i))*(col(j)-col(k))/col(i);
col(m)=col(c)(col(i))*(col(j)-col(k))/col(i);
col(n)=col(d)(col(i))*(col(j)-col(k))/col(i);

now it works fine.

Thanks,
Andreas


Penn Posted - 06/08/2010 : 03:55:30 AM
Hi Andreas,

I have made a new worksheet with three columns A, B and C in Origin 7.5, and fill with some numbers. Then create a new ogs file (test.ogs) under user files folder, and add the following script in this ogs file.

sum(%e_a);
sumTx=$(sum.total);
sum(%e_b);
SumTy=$(sum.total);
sum(%e_c);
SumTz=$(sum.total);
sumtx=;
sumty=;
sumtz=;

Then execute command
run test.ogs;
in the script window, the three sum values are typed correctly in the script window. So I think it works fine.

Could you please provide more details?

Penn

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