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
 Howto include MOCA dll into OriginC?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

marko

Germany
112 Posts

Posted - 03/31/2003 :  10:58:37 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

we just tried to find documentation concerning the use of MOCA in OriginC, but were unable to find anything. Perhaps its because we used the evaluation version of O7...

Does somebody know how to include a user moca object in OriginC?

Marko

srmcarneir

Brazil
33 Posts

Posted - 03/31/2003 :  3:48:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Marko,

Have you tried the Programming Guide Help for Origin 7?
There we can find sth as follows. Hope that may be of some help.
- - - - - - - - - - -

Accessing Functions in External DLLs

Your Origin C function can make calls to functions in external DLLs created by C, C++, or Fortran compilers. To do this, you must include an include directive for the header file which declares the functions in your external DLL. Your include directive can specify a relative or an absolute path. For example:

#include "temp\myFile.h" // in the \OriginC\temp folder
#include <temp\myFile.h> // in the \OriginC\system\temp folder
#include "c:\myFolder\myFile.h" // in specified path
To distinguish these external DLL functions from Origin C functions, you must include the following Origin C pragma directive in the header file, directly before your external DLL function declarations:

#pragma dll(fileName)
where fileName is either a relative or an absolute path and file name of the DLL. For example:

#pragma dll(myDLL) // in the Origin folder
#pragma dll(c:\myFolder\myDLL) // in specified path
(Note: You don't need to include the .dll extension in the file name.)

All function declarations after this pragma directive will be considered external and from this specified DLL. This assumption is made until a second #pragma dll(fileName) directive is reached, or until the end of the file is reached.

When calling a function in an external DLL, the Origin C compiler supports three calling conventions: __cdecl (default), __stdcall, and __fastcall. These calling conventions determine the order in which arguments are passed to the stack as well as which function (Origin C calling function or called external function) cleans the arguments from the stack.

In each case, the calling convention is specified in the external function declaration using the syntax:

returnType callType funcName(parameterList);
In this case you would replace callType with the desired calling convention (__cdecl, __stdcall, or __fastcall). Because the default calling convention is __cdecl, you need not include this keyword in your external function declaration.

1) The default calling convention is __cdecl. With this type of external function call, the argument passing order is from right to left and the calling Origin C function cleans the stack.

2) In the __stdcall calling convention, the argument passing order is from right to left and the called external function cleans the stack. You must supply the .h file to declare functions that are called using this convention.

3) In the __fastcall calling convention, the arguments are passed in registers, when possible. Otherwise the argument passing order is from right to left. The called external function cleans the stack. You must supply the .h file to declare functions that are called using this convention.

The following example function declaration uses the __stdcall calling convention:

int __stdcall GetWindowText(HWND, LPTSTR, int);


Ricardo Carneiro
Go to Top of Page

marko

Germany
112 Posts

Posted - 04/01/2003 :  01:58:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

yes I saw that section! BUT, it is not specific to MOCA dlls, because it only shows how to handle functions in dlls. That's all clear and handy. BUT, HOW DO I ACCESS MOCA's OBJECT VARIABLES?

MOCA uses a certain way of passing variables, allows also read-only variables and has a specific way of passing variables to object methods. That is what I couldn NOT find in the manual up to now. Also the help files do not give any helpful hint concerning this!!!

Well, you could work around all this, but I thought that many of Origins own objects are of MOCA type, so it shouldn't be a problem to use user-created MOCA objects as well... But maybe I am mistaken!

Marko

Go to Top of Page

eparent

118 Posts

Posted - 04/01/2003 :  09:48:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

You can access MOCA objects from Origin C. The following is an Origin C function that accesses LabTalk's Image object to export the active graph.

int test_moca_obj()
{
Page pg = Project.ActiveLayer().GetPage();
if( pg.GetType() != EXIST_PLOT )
return 1;

using Image = LabTalk.Image;

Image.FileName$ = "c:\\test.bmp";
Image.ShowOptions = 0;
int n = Image.Export.PagePixel("BMP", 640, 480, 24, 0);
if( n )
return 1;

return 0;
}


Go to Top of Page

marko

Germany
112 Posts

Posted - 04/02/2003 :  03:39:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi eparent,

thanks for your helpful advice! We'll give that a try. Looks like that should seamless integrate our old MOCAs into OriginC. Suprising that the syntax looks like labtalk in OriginC (mo.var$)! :)

What are future prospects for MOCA? Are you in future still going to use this kind of mechanisms or will you switch in Origin V8.0 to another way of handling user supplied dlls. In case you'll improove OOP behaviour of OriginC one might suspect MOCA gets useless...

But perhaps I fear something unlikely... Looks like most of Origin's own objects seem to be MOCA themself, right?

Marko

Go to Top of Page

schalkbe

Germany
9 Posts

Posted - 04/02/2003 :  08:08:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello eparent,

thank you for the hint with the LabTalk object!
I just tested it with an old MOCA object I used in Origin 6. I now can reuse this object in OriginC and access all methods and attributes. It works great. I am impressed!

Bernhard

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