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
 struggling to calculate cumal
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

carsten

Switzerland
78 Posts

Posted - 12/15/2008 :  1:40:13 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and SR (Select Help-->About Origin):
Operating System:

I try the to calculate the accumulative hours with the following code:


// open script window to show prompts
ty -a;

GetString (Enter Source Worksheet name) (RawData);
%P=%B;
type "Source Worksheet: "%P;
// %Q="NormData"; // Target Wks
get %P_Lamp -e TotalMeas; // Total Measurements
NoLamps=1;
GetNumber -s (Number of Lamps of same configuration) NoLamps;
NoLamps=;
// get Common_Lamp -e NoLamps; // Number of Lamps
// no of measurement of each lamp: NoMeas
NoMeas=TotalMeas/NoLamps; // must be an integer
if (mod(TotalMeas ,NoLamps) > 0) type -b "mod(TotalMeas ,NoLamps) > 0";
NoMeas=;
// calculate cumulative hours for each lamp
For (i=1; i<=TotalMeas;i+=NoMeas)
%P_Std[i]=0.1; // initial time
For (ii=1; ii<=NoMeas-1;ii++)
{
S1=(%P_Date[ii+1]-%P_Date[ii])*24.0 + (%P_TIME[ii+1]-%P_TIME[ii])*24.0;
%P_Std[ii+1]=%P_Std[ii]+S1;
// check parameter
type "Std[ $(ii)] = $(%P_Std[ii+1]) == $(%P_Std[ii]) + $(S1)";
};
};

the wks with input and output date looks as follows:


Date Time Std Lamp (<= column heads)
23.07.2007 09:30 0,10 1
24.07.2007 13:30 32,10 1
25.07.2007 12:00 53,10 1
26.07.2007 11:00 75,10 1
27.07.2007 09:15 95,60 1
30.07.2007 15:00 179,10 1
02.08.2007 07:45 236,60 1
06.08.2007 10:40 338,43 1
14.08.2007 09:40 528,43 1
20.08.2007 10:30 674,10 1
27.08.2007 10:20 841,77 1
12.09.2007 11:00 1227,10 1
18.09.2007 08:22 1365,83 1
26.09.2007 08:22 1557,83 1
04.10.2007 12:45 1758,60 1
25.10.2007 09:00 2255,10 1
09.11.2007 09:00 2615,10 1
16.11.2007 16:11 2797,47 1
30.11.2007 09:40 3120,43 1
14.12.2007 09:10 3455,43 1
21.12.2007 11:40 3628,43 1
03.01.2008 10:10 3937,43 1
18.01.2008 10:47 4298,05 1
01.02.2008 11:00 4624,10 1
13.02.2008 09:20 4910,43 1
19.03.2008 08:50 5749,93 1
31.03.2008 14:15 6043,35 1
11.04.2008 14:15 6307,35 1
23.04.2008 13:40 6594,77 1
06.05.2008 15:00 6908,10 1
07.05.2008 10:50 6927,93 1
20.05.2008 11:35 7240,68 1
17.06.2008 15:00 7916,10 1
02.07.2008 11:11 8272,28 1
23.07.2008 08:00 -5,80E+07 1
30.07.2008 15:45 -5,80E+07 1
13.08.2008 15:46 -5,80E+07 1
28.08.2008 09:40 -5,80E+07 1
10.09.2008 13:45 -5,80E+07 1
24.09.2008 11:25 -5,80E+07 1
08.10.2008 11:00 -5,79E+07 1
08.12.2008 16:08 -5,79E+07 1


From Date = 23.7.2008 the result gets worse
In order to check what happen I print out the parameter values (see code line after // check parameter

Std[ 31] = 7240,68333 == 6927,93333 + 312,75
Std[ 32] = 7916,1 == 7240,68333 + 675,41667
Std[ 33] = 8272,28333 == 7916,1 + 356,18333
Std[ 34] = -5,79517E7 == 8272,28333 + -5,79599E7
Std[ 35] = -5,79515E7 == -5,79517E7 + 175,75
Std[ 36] = -5,79511E7 == -5,79515E7 + 336,01667
Std[ 37] = -5,79508E7 == -5,79511E7 + 353,9
Std[ 38] = -5,79505E7 == -5,79508E7 + 316,08333
Std[ 39] = -5,79501E7 == -5,79505E7 + 333,66667
Std[ 40] = -5,79498E7 == -5,79501E7 + 335,58333
Std[ 41] = -5,79483E7 == -5,79498E7 + 1469,13333

The problem is:
why works the code up to Std[33] and fails for the next steps?

Any hint is appreciated

Carsten

carsten

Switzerland
78 Posts

Posted - 12/16/2008 :  04:34:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Meanwhile I could resolve the problem:

Due to a copy (Excel) paste (Origin) process part of the data was 'infected'. When copied into a new Excel sheet and from this wks a second copy action was made then subsequent pasting the data into an Origin wks the code works as expected.

Carsten
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