| T O P I C R E V I E W |
| rpaczkowski |
Posted - 03/30/2005 : 1:45:27 PM Origin Version (Select Help-->About Origin): 7.5 SR5 Operating System: Win 2000
Me again!
I am only trying to copy the absolute value of all rows in one column into another column using: //Find last used row int reihe = 0; string strinhalt; do { wks.GetCell(reihe,0,strinhalt); reihe = reihe +1; } while (strinhalt !=""); //copy abs values in new row int n=1; double abso, wert; string strwert; for (n; n<=reihe-1; ++n) wks.GetCell(n,0,strwert); wert = atoi(strwert); printf("Value row %i is %f\n ",n-1, wert); abso=fabs(wert); wks.SetCell(n+1,1,abso); return;
It does not work! The output is:"Value row 10 is 0.00000". However, I have only values in rows 1 through 9 and the output tells me that the loop is only executed once with n=11. Why?
Ralph |
| 5 L A T E S T R E P L I E S (Newest First) |
| easwar |
Posted - 04/01/2005 : 09:46:19 AM Hi Ralph,
We are improving the Origin C language reference documentation and in the next version such instances of missing information should not be there. The page I pointed to in the previous post is a temporary solution in that sense. We will then integrate many such examples into the documentation in the next version so they are readily available in the product itself.
Easwar OriginLab
|
| rpaczkowski |
Posted - 04/01/2005 : 08:25:24 AM Easwar,
I am sure that a lot of people who start programming Origin first have to learn C andare glad to find a forum where their easy questions are answered. But then it may be a good idea to have 2 forums, one for general questions about C (and/or Labtalk) and one for C-questions specific to programming Origin. I also think that it would help to have the help-files for Origin reworked. If you look e.g. for *GetPage, you find:
PropertySheet::*GetPage Prototype: PUBLIC PropertyPage *GetPage(int nPage) Remarks: Parameters: Return values: Example: Summary: Sample data: Header file: Dialog.h See also:
And there are many more like this. Not very helpful from my point of view.
I will think about adding more example programming examples.
Ralph |
| easwar |
Posted - 03/30/2005 : 3:02:21 PM Hi Ralph,
The need to put multiple statements inside {} with a for loop is standard C and not special to Origin C.
Please do not hesitate to post such questions...we don't assume that users know C programming, and we want to help as much as we can.
There is a page on our website accessible from the Support area, where we are putting together a collection of "practical" examples that show how to use Origin C for doing various things in Origin: http://www.originlab.com/index.aspx?s=9&lm=71&pid=268
Please take a look and if you have suggestions on adding examples that would be useful, please let us know.
Easwar OriginLab
|
| rpaczkowski |
Posted - 03/30/2005 : 2:53:25 PM Easwar,
for one, your method is way more elegant than mine! Secondly, I feel pretty stupid forgetting the {}. It works just fine with them. The reason is probably that I am learning C out of a book for C and the codes there are sometimes different from OC, e.g. there are no {} for a for{} loop. Thanks a lot.
Ralph
Edited by - rpaczkowski on 03/30/2005 2:56:49 PM |
| easwar |
Posted - 03/30/2005 : 2:33:22 PM Hi Ralph,
If I understand you correctly - you want to set say col(2) of wks to hold abs values of numbers in col(1) - you can simply do the following:
void test() { Worksheet wks = Project.ActiveLayer(); Dataset ds1(wks, 0); Dataset ds2(wks, 1); ds2 = fabs(ds1); }
In your code by the way, perhaps the problem is there is no {} that encloses all needed statements in your for() loop.
Easwar OriginLab
|
|
|