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
 debugging e.g. pareto chart
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

tpflanz

Germany
Posts

Posted - 07/11/2005 :  08:26:23 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Writing formulas in 7.5 for new columns I frequently don't know how to debug.
e.g. the following code example in the pareto chart entry in this forum didn't work for me:

Data1_D[1]=Data1_C[1];
for(ii=2; ii<=wks.maxrows; ii++)
Data1_D[ii]=Data1_C[ii]+Data1_D[ii-1];

There are no error messages whatsoever - how can I find out how to make it work?

More than that, are there any examples how to manipulate data and detailled examples for programming, more than those already given at the installation? How can I improve my data manipulation skills with Origin?

Thomas M

Germany
Posts

Posted - 07/11/2005 :  09:47:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I guess you forgot some brakes. Try:

Data1_D[1]=Data1_C[1];
for(ii=2; ii<=wks.maxrows; ii++)
{
Data1_D[ii]=Data1_C[ii]+Data1_D[ii-1];
}
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 07/11/2005 :  10:24:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Brackets {} are only necessary for scripts with more than one line. This script should work without the brackets and I'd have to see the context to know why it failed.

You can set echo=1 to have error messages printed to the script window. Debugging tools are also available in CodeBuilder...

Help > Programming > Code Builder User's Guide > Debugger > Debugging LabTalk Scripts

OriginLab's Knowledge Base is the best place to look for programming examples...

http://www.originlab.com/index.aspx?s=9

You can find more examples in these forums and at the Origin WebRing member sites.

Mike Buess
Origin WebRing Member
Go to Top of Page

greg

USA
1378 Posts

Posted - 07/12/2005 :  12:12:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
User Mike Buess is correct that braces are not needed in a for loop executing a single statement.
The code should work provided you have values in column C in the Data1 worksheet.

Go to Top of Page

tpflanz

Germany
Posts

Posted - 07/20/2005 :  08:51:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
O.K. - still the same problem

I follow this procedure:
1) Original Data
A(X): a, b, c, d
B(Y): 2, 3, 1, 4

2) Sort Descending:
A(X): d, b, a, c
B(Y): 4, 3, 2, 1

3) Calculate %:
A(X): d, b, a, c
B(Y): 4, 3, 2, 1
C(Y): 40, 30, 20, 10

4) Cumulate:
A(X): d, b, a, c
B(Y): 4, 3, 2, 1
C(Y): 40, 30, 20, 10
D(Y): 40, 70. 90, 100

5) I open a script window over 'window - script window'
6) I enter:
Data1_D[1]=Data1_C[1]
7) it shows 40 in cell D[1]
8) I enter: for(ii=2; ii<=wks.maxrows; ii++)
Data1_D[ii]=Data1_C[ii]+Data1_D[ii-1]

and nothing happens - what am I doing wrong?
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 07/20/2005 :  10:24:11 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
At which stage are you running the script?

> If the wks is at stage 4) then nothing will change when you run the script because col(D) already contains the results.

> If the wks is at stage 3) then the script should produce stage 4). These are only reasons for failure that I can think of...

1. The wks Data1 is not active. If that's the case replace wks.maxrows with Data1!wks.maxrows.
2. Column D does not exist.
3. You're not executing correctly from the script window. You must select both lines of script and then press Enter.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/20/2005 10:31:05 AM
Go to Top of Page

tpflanz

Germany
Posts

Posted - 07/21/2005 :  05:46:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
cheers Mike,
I didn't know I had to select both lines - now it works
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