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 for Programming
 LabTalk Forum
 how to store sum of column in variable?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Andreas_D

Germany
11 Posts

Posted - 06/02/2010 :  10:42:49 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Penn

China
644 Posts

Posted - 06/08/2010 :  03:55:30 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

Andreas_D

Germany
11 Posts

Posted - 06/08/2010 :  06:08:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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


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