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
 How to transfer address of string variable Z to a DLL?
 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 - 02/25/1999 :  7:36:00 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

is there a chance to transfer the address of a LabTalk string (e.g. Z, because of its length) to an external DLL? I ask since I am limited in the length of the parameter string which I have to use in my dll command call. So I thought it would be the best just to transfer an address to an appropriate prepared parameter string instead of using it directly in my dll calling.

Thanks for any help.

Marko

eparent

118 Posts

Posted - 02/25/1999 :  5:09:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you call your DLL's function with no other arguments then you are as close as you can get to receiving the address of %Z. Unfortunately it must be treated as a pointer to a constant string.

For example if a DLL has the following function
int FAR PASCAL myDLLfunction(HWND hWnd, LPCSTR lpstr);

and you call this function from LabTalk with
DLL myDLL myDLLfunction %Z

then lpstr is pointing to a copy of %Z. Its important to remember that lpstr is pointing to a constant string. Changing the contents of it will most likely cause unwanted results (possibly crashing Origin).

Go to Top of Page

marko

Germany
112 Posts

Posted - 02/26/1999 :  7:52:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Eparent,

thanks again for your attention.

Funny, although I code C and Pascal already since years the obvious things you don't get. Certainly, it's already an address which you transfer with LPCSTR... :|

But it's a great feature that this way also enables me to access the huge space in %Z!!!

Thanks alot. So I can avoid using a ramdisk for parameter buffering. That's great.

But if I once started this subject, perhaps I could go further in my speculations and imaginations. Is there a possibility to statically store information in a DLL? I mean to initialize my DLL functions with some parameters and still be able to use them half an hour later... This means that the DLL shouldn't be unloaded by Origin in the meantime... Suggestions?


Thanks.
Marko

Go to Top of Page

eparent

118 Posts

Posted - 02/26/1999 :  12:00:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Origin unloads the DLL after executing your DLL's function. As you know unloading the DLL will cause you to lose all your data in the DLL. One suggestion is to use an INI file. When the DLL is loaded you get the values from the INI and on unloading you save your values to the INI. This is a simple and clean solution.

Another suggestion is to write your DLL as an Add-On DLL. Are you familiar with the -A option of the DLL command? The -A option maps the specified DLL to a new LabTalk object. These DLLs are not unloaded until Origin exits and are a great way of expanding LabTalk. The -A option will not work with any DLL. You must write your DLL to the MODLL specifications and add the MODLL library to your VC project. What version of Origin and VC are you using?

Go to Top of Page

marko

Germany
112 Posts

Posted - 03/01/1999 :  7:27:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

well, I mentioned ramdisk because it would probably the quickest method to get fast access to the data I need to transfer to the dll. Suppose I need to call the dll quite often then it wouldn't be so nice to have it reading all the time on my hard disk. That is why I came to this solution. I mean as long as it would be in the hard disk cache it shouldn't be a problem too.... Don't know.

But anyway. The only problem is that I would have a huge amount of parameters to transfer to the dll. Without the %Z variable it is impossible by now. Luckyly this opportunity exists, so I could also work with that. So I think it is not worth the huge capabilities I could have with MODLL, since the dll function actually computes a certain data set and need some input columns from Origin, but doesn't need interaction between Origin and the dll in this process...

But anyway, maybe for this purpose one could use MODLL though, but then it's the question whether it needs to be bought together with Origin Professional or not? Since I own only Origin 5.0 it would require to upgrade, which is not so necessary.

Okay, thanks for your help. I am really surprised any happy that contact with Microcal is of this high level. Thanks alot.

Marko

Go to Top of Page

marko

Germany
112 Posts

Posted - 03/01/1999 :  7:39:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Well, currently I am using Origin 5.0 (but not Professional!) and Visual C++ 5.0.

Somewhere I already saw examples for MODLL, but as I understood the code was incomplete and unusable for me. Also it seemed to me that it is quite complicated to code such DLLs. So maybe I should just go the way using an intermediate file to store information, say on a ramdisk which I would have to install then...

What's your opinion about that?

On the other hand, is it possible to get full source code with examples for the MODLL for O5.0? And is it really that complicated to use?

Okay, that's all so far. Thanks for your quick replies.

Marko

P.S.: One thing I want to mention! Since I am quite a newbee in Windows programming I have to admit that the combination of self-written code together with the displaying capabilities of Origin 4/5 make life easier for physicist like me. So I don't need to invent the wheel everytime again and again... Great tool!

Go to Top of Page

eparent

118 Posts

Posted - 03/01/1999 :  7:56:00 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If your DLL does not need to communicate directly with Origin and you don't mind having your DLL loaded and unloaded everytime you call it then MODLL is not necessary. Adding an INI file to your current DLL is a great way of saving and restoring settings and the Windows API makes it easy.

You mention "ramdisk". I understand a ramdisk to be a portion of RAM setup to simulate a disk drive. Is this what you are refering to?

MODLL does come with examples and yes, it is a bit more complicated to setup a MODLL but the additional benefits are needed for some tasks. Also, MODLL requires some C++. What is your DLL's task and how are you using it with Origin?

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