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
 Calling my own code from a fitting function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

sjwerkema

USA
2 Posts

Posted - 01/30/2016 :  8:05:20 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: 8.6.0 (64-bit) Sr3
Operating System: Windows 7

I am trying to create a user-defined fitting function that calls functions that I've written in Origin C. If I include the header file that contains the declarations I need and my function prototypes, I get a "Error, duplicate variable names in declaration" error for the first declaration in the header file when I attempt to compile. If I don't include this header, the compiler complains because it can't find my functions. What is the procedure for using my own code in a fitting function?


Steve Werkema
Fermi National Accelerator Laboratory

jasonzhao

China
262 Posts

Posted - 02/01/2016 :  05:09:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Would you please tell me the path of your 'header file' and corresponding '.c' file,
and the code of how do you include the header file that contains the declarations,
and it's better to show us the prototype of the Origin C function.

Best regards!
Jason
OriginLab Technical Service
Go to Top of Page

sjwerkema

USA
2 Posts

Posted - 02/01/2016 :  09:05:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jason,

Thanks for the quick response.

The path of my header file and correspoonding '.c' file is:
Z:\Projects\Origin\OriginC\ProjectTemp\MagnetMeasurementAnalysis.h
Z:\Projects\Origin\OriginC\ProjectTemp\MagnetMeasurementAnalysis.c

Z: is a network drive.

These files show up in my Origin User folder and build without error. I can use functions defined in MagnetMeasurementAnalysis.c to set column values for worksheets that are in my project.

I include these files in my fitting function with the statement:
#include "Z:\Projects\Origin\OriginC\ProjectTemp\MagnetMeasurementAnalysis.h"

The prototype statement (in MagnetMeasurementAnalysis.h) for the function I use in my fitting function is:
int Fact(int n);

I can email the code to you if that would help.

Regards,



Steve Werkema
Fermi National Accelerator Laboratory
Go to Top of Page

jasonzhao

China
262 Posts

Posted - 02/01/2016 :  9:26:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

In fact Origin has the fact function internal,
http://www.originlab.com/doc/LabTalk/ref/Fact-func
you can call it directly in your function expression;

If you write the fact function by yourself, you may need to consider the data type, because in Origin C fitting function, the parameter has a default type of double, but your Fact function has a return type of int, you may need to convert, if necessary.

and if you want us to check the file, you can send to tech@originlab.com.


Best regards!
Jason
OriginLab Technical Service
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