Re: moving data from one place to another in a text file
From: Richard (riplin_at_Azonic.co.nz)
Date: 02/26/05
- Next message: Lueko Willms: "Re: Treeviews"
- Previous message: Kellie Fitton: "Re: Treeviews"
- In reply to: Robert Wagner: "Re: moving data from one place to another in a text file"
- Next in thread: William M. Klein: "Re: moving data from one place to another in a text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 26 Feb 2005 13:18:37 -0800
> The calling sequence to a .dll or .so is defined by the operating
system,
> independent of language.
You are now attempting to restrict what you meant by 'Calling
methodology' to that of specific types of calls. However, you once
again are a wonderful mine of misinformation:
"""Calling DLL's under Windows
Users of ACUCOBOL-GTŪ under Windows have the ability to call routines
packaged in Dynamic Link Libraries (DLL's) written in almost any
language. To achieve this there are a few things you need to know.
Firstly, there are two calling 'conventions', which specify how
parameters are passed to the DLL, under Windows, the C convention and
the Pascal convention. You can choose which convention to use by
setting the DLL-CONVENTION environment variable, remember you can use
SET ENVIRONMENT to set this. If you're not sure which convention is
used by a DLL just try one. If you've got it wrong you'll know pretty
quickly (can you spell GPF?).
Now we need to know how to call the DLL. If the DLL has only one
'entry-point' i.e. it only has one sub-routine packaged in it, and then
we can just call it by name:
CALL "MYDLL.DLL" USING PARAM-1, PARAM-2.
The Windows runtime always looks for a file with the '.DLL' extension
if it doesn't find a COBOL program with the specified name, so we could
just say CALL "MYDLL". However we find it's easier to keep track of
what's going on if the extension is specified in the call.
Where the DLL has more than one entry-point we just call the DLL by
name to initialise it, then call the routine by name to run it. Let's
imagine that 'MYDLL.DLL' contains two routines 'routine1' and
'routine2'. We want to call 'routine2', so we code:
CALL "MYDLL.DLL".
CALL "routine2" USING PARAM-3.
The final thing we need to know is what format the DLL expects the
parameters to be in. The main thing here is whether it expects to get
the parameters as values or addresses. The default for ACUCOBOL-GTŪ is
to pass the address, also known as 'by reference'. If the DLL expects a
value, then you must specify BY VALUE on the parameter. Let's imagine
that we're calling 'routine1' which expects a number as its first
parameter and the address of a data item as its second; C programmers
will call this a 'pointer'. Since we've already called 'MYDLL.DLL' we
can just go ahead and call 'routine1':
CALL "routine1" USING BY VALUE WS-NUMBER, WS-DATA-ITEM.
And that's it! It's really straightforward and opens up many
possibilities in the Windows world.""""
Or perhaps:
"""Q. Why do I get "Bad Calling Convention" when trying to call my VC++
dll from VB?
A. Visual Basic only supports calling functions in Dlls that are
declared with the __stdcall calling convention. This is different from
the default convention in VC++, __cdecl, which stands for "C' calling
convention. The two are not the same (but that's another topic) and are
not interchangeable. The solution? make sure you declare your dll's
functions as __stdcall.
"""
- Next message: Lueko Willms: "Re: Treeviews"
- Previous message: Kellie Fitton: "Re: Treeviews"
- In reply to: Robert Wagner: "Re: moving data from one place to another in a text file"
- Next in thread: William M. Klein: "Re: moving data from one place to another in a text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|