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
 Forum for Origin C
 Get Cell values
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rpaczkowski

USA
Posts

Posted - 03/30/2005 :  1:45:27 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

easwar

USA
1965 Posts

Posted - 03/30/2005 :  2:33:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Go to Top of Page

rpaczkowski

USA
Posts

Posted - 03/30/2005 :  2:53:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

easwar

USA
1965 Posts

Posted - 03/30/2005 :  3:02:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Go to Top of Page

rpaczkowski

USA
Posts

Posted - 04/01/2005 :  08:25:24 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
Go to Top of Page

easwar

USA
1965 Posts

Posted - 04/01/2005 :  09:46:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

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