From: Stephen on
I'm in need of exporting a DLL in either Delphi or C. Delphi would be
the best.
Here is the file definition:
Questions:
Do I use stdcall or C calls?

Procedure PIBSINIT(var pc : pcT); stdcall ; external 'mio.dll';
Procedure PIBSEXIT(var pc : pcT); stdcall ; external 'edrio.dll';

Does the array name have to Match?

How do I translate 03, 05 and what does it mean?

Thanks

Stephen K. Miyasato

type
pPCT= ^pcT;
pcT = packed record //PIBS Comm
pc-version : array[0..5]of char; //6
pc-version-date : array[0..7]of char ;//8
pc-version-date : array[0..31]of char ; //32

01 pibs-comarea.
03 pc-version pic x(06).
03 pc-version-date pic x(08).
03 pc-program-name pic x(32).
03 pc-error-code pic x(03).
03 pc-first-call-flag pic x(01).
03 pc-mibs pic x(01).
03 pc-init-flag pic x(01).
03 pc-filst.
05 pc-file-status.
07 pc-fs1 pic x(01).
07 pc-fs2 pic x(01).
05 pc-fsx pic x(03).
03 filler pic x(01).
03 pc-cdate.
05 pc-cen pic x(02).
05 pc-date.
07 pc-year pic x(02).
07 pc-month pic x(02).
07 pc-day pic x(02).
03 pc-start-time pic x(04).
03 pc-file-cmd pic x(02).
03 pc-file-name pic x(24).
03 pc-next-acct-num pic x(10).
03 pc-next-pat-num pic x(10).
03 pc-debug pic x(02).
03 pc-last-closed-date pic x(08).

From: Tim Van Holder on
Stephen wrote:
> I'm in need of exporting a DLL in either Delphi or C. Delphi would be
> the best.
> Here is the file definition:
> Questions:
> Do I use stdcall or C calls?

I guess that depends on how the COBOL DLLs were compiled/linked.
When in doubt, look at the exported symbols from the DLL.

> Procedure PIBSINIT(var pc : pcT); stdcall ; external 'mio.dll';
> Procedure PIBSEXIT(var pc : pcT); stdcall ; external 'edrio.dll';

> Does the array name have to Match?

No, you're just passing a point to a bunch of bytes;
the call doesn't tell the COBOL program what your local
variables are called.

> How do I translate 03, 05 and what does it mean?

The COBOL level numbers only show hierarchy

03 pc-cdate.
05 pc-cen pic x(02).
05 pc-date.
07 pc-year pic x(02).
07 pc-month pic x(02).
07 pc-day pic x(02).

defines 4 real fields, and 2 grouping names that can
be addressed in COBOL to get the concatenation of the
underlying fields. For your purposes you should see
what info you actually need. You can go for

pc-cen array[0..1] of char;
pc-year array[0..1] of char;
pc-month array[0..1] of char;
pc-day array[0..1] of char;

to give the same set of 4 field with pieces of the full
ISO date, or you could just put

pc-cdate array[0..7] of char;

Or you could make each group a separate record type.
It all depends on what parts of the commarea need to
be accessed by the Delphi code.
From: Alain Reymond on
Tim Van Holder a ?crit :
> Stephen wrote:
>> I'm in need of exporting a DLL in either Delphi or C. Delphi would be
>> the best.

Tim,

You will find here :
http://supportline.microfocus.com/examplesandutilities/nesamp.asp#MixedLanguage

examples on how to call a cobol dll from C and from Delphi.
It is for MicroFocus of course.

Regards.

Alain
From: Stephen on
>>I guess that depends on how the COBOL DLLs were compiled/linked.
>>When in doubt, look at the exported symbols from the DLL

How is that done? using TDUMP.exe? see below
What about the calling conversions stdcall or cdel(?);

Thanks for the reply,

I'll give it a try

Stephen K. Miyasato

TDUMP result below

DOS File Size 73000h (471040. )
Load Image Size 450h ( 1104. )
Relocation Table entry count 0000h ( 0.
Relocation Table address 0040h ( 64.
Size of header record (in paragraphs) 0004h ( 4.
Minimum Memory Requirement (in paragraphs) 0000h ( 0.
Maximum Memory Requirement (in paragraphs) FFFFh ( 65535.
File load checksum 0000h ( 0.
Overlay Number 0000h ( 0.

Initial Stack Segment (SS:SP) 0000:00B8
Program Entry Point (CS:IP) 0000:0000


Portable Executable (PE) File

Header base: 00000080

CPU type 80386
Flags 210E [ executable backwards 32bit library ]
DLL flags 0000 [ ]
Linker Version 3.0
Time stamp 428A90F4 : Tue May 17 14:48:52 2005
O/S Version 4.0
User Version 0.0
Subsystem Version 4.0
Subsystem 0002 [ Windows GUI ]
Object count 00000005
Symbols offset 00000000
Symbols count 00000000
Optional header size 00E0
Magic # 10B
Code size 00057C00
Init Data size 0003C000
Uninit Data size 00000000
Entry RVA 000586F0
Image base 61000000
Code base 00001000
Data base 00059000
Object/File align 00001000/00000200
Reserved 00000000
Image size 00097000
Header size 00000400
Checksum 00000000
Stack reserve/commit 00100000/00001000
Heap reserve/commit 00100000/00001000
Number interesting RVAs 00000010
Name RVA Size
------------------ -------- --------
Exports 00059000 0000047F
Imports 00089000 00000050
Resources 00000000 00000000
Exceptions 00000000 00000000
Security 00000000 00000000
Fixups 0008A000 0000CB7C
Debug 00000000 00000000
Description 00000000 00000000
Global Ptr 00000000 00000000
TLS 00000000 00000000
Callbacks 00000000 00000000
Bound Imports 00000000 00000000
Import Addr Table 000891C8 00000178
Delayed Imports 00000000 00000000
COM Runtime 00000000 00000000
reserved 00000000 00000000

Object table:
# Name VirtSize RVA PhysSize Phys off Flags
-- -------- -------- -------- -------- -------- --------
01 .text 00057BDA 00001000 00057C00 00000400 60000020 [CER]
02 .rdata 0000047F 00059000 00000600 00058000 40000040 [IR]
03 .data 0002E218 0005A000 0000D400 00058600 C0000040 [IRW]
04 .idata 00000702 00089000 00000800 00065A00 C0000040 [IRW]
05 .reloc 0000CD84 0008A000 0000CE00 00066200 42000040 [DIR]

Key to section flags:
C - contains code
D - discardable
E - executable
I - contains initialized data
R - readable
W - writeable

*********************************************************************
Section: Import
File Offset: 00065A00 (416256)
ImportLookUpTblRVA:00089074
Time Stamp: 00000000
Forwarder Chain: 00000000 (index of first forwarder reference)

Imports from cblrtss.dll
(ord. = 1475)
(ord. = 1370)
(ord. = 1477)
(hint = 0366) _mFgF806
(hint = 0365) _mFgF805
(hint = 0023) CBL_FILE_ERROR
(ord. = 1001)
(ord. = 1071)
(ord. = 1070)
(hint = 0362) _mFgF802
(ord. = 1454)
(ord. = 1460)
(hint = 0363) _mFgF803
(ord. = 1368)
(ord. = 1092)
(ord. = 1522)
(ord. = 1365)
(ord. = 1363)
(ord. = 1524)
(ord. = 1364)
(hint = 035F) _mFgCE
(ord. = 1471)
(ord. = 1359)
(ord. = 1355)
(hint = 0061) CBL_REF_EXT_DATA
(hint = 03D2) _mFiD7F5
(hint = 0359) _mFfindp
(hint = 0409) mF_eloc
(hint = 0021) CBL_EXIT_PROC
(hint = 007D) CBL_SUBSYSTEM
(hint = 0002) CBL_ALLOC_MEM
(hint = 0026) CBL_FREE_MEM
(hint = 0373) _mFgF813
(hint = 0371) _mFgF811
(hint = 0397) _mFiD791
(ord. = 1015)
(ord. = 1006)
(hint = 0064) CBL_RESNAME
(hint = 0395) _mFiD78F
(hint = 0096) CBL_TOUPPER
(hint = 0077) CBL_SETSEMA
(hint = 0062) CBL_RELSEMA
(hint = 009B) CBL_UNLOCK
(hint = 0030) CBL_GET_RECORD_LOCK
(hint = 0080) CBL_TEST_RECORD_LOCK
(hint = 0027) CBL_FREE_RECORD_LOCK
(hint = 0016) CBL_DELETE_FILE
(hint = 0008) CBL_CHECK_FILE_EXIST
(hint = 0054) CBL_OPEN_FILE
(hint = 0055) CBL_OPEN_VFILE
(hint = 0011) CBL_CREATE_FILE
(hint = 000C) CBL_CLOSE_VFILE
(hint = 000B) CBL_CLOSE_FILE
(hint = 005A) CBL_READ_FILE
(hint = 0060) CBL_READ_VFILE
(hint = 009D) CBL_WRITE_FILE
(hint = 00A6) CBL_WRITE_VFILE
(hint = 0361) _mFgF801
(hint = 0024) CBL_FLUSH_FILE
(hint = 03B9) _mFiD7CB
(hint = 000D) CBL_CMPNLS
(hint = 000E) CBL_CMPTYP
(hint = 00A7) CBL_XOR
(ord. = 1294)
(hint = 0392) _mFiD78C
(hint = 037D) _mFginitdat_dll
(ord. = 969)
(ord. = 733)
(ord. = 968)
(hint = 0353) _mFdllinit
(hint = 0354) _mFdllterm
(hint = 0357) _mFerr2
(hint = 0384) _mFgproglink
(ord. = 1464)
(ord. = 1463)
(hint = 00B6) EXTFH
(hint = 0382) _mFgprogchain
(hint = 038C) _mFgtypecheck
(hint = 035E) _mFgAE
(ord. = 1333)
(hint = 0383) _mFgprogcheckexit
(hint = 038A) _mFgprogunchain
(ord. = 1244)
(ord. = 1156)

Imports from MSVCRT40.dll
(hint = 023D) _adjust_fdiv
(hint = 041E) malloc
(hint = 02A7) _initterm
(hint = 03EB) free

Imports from KERNEL32.dll
(hint = 0137) GetVersion
(hint = 0140) GlobalAlloc
(hint = 0147) GlobalFree

********************************************************
From: Sergey Kashyrin on
MicroFocus Cobol is using cdecl convention, i.e. in C++

extern "C" void __declspec(dllexport) MYFUNC(char * parm1, char * parm2,
....)


"Stephen" <miyasat(a)gmail.com> wrote in message
news:1158817795.522911.115330(a)d34g2000cwd.googlegroups.com...
> I'm in need of exporting a DLL in either Delphi or C. Delphi would be
> the best.
> Here is the file definition:
> Questions:
> Do I use stdcall or C calls?
>
> Procedure PIBSINIT(var pc : pcT); stdcall ; external 'mio.dll';
> Procedure PIBSEXIT(var pc : pcT); stdcall ; external 'edrio.dll';
>
> Does the array name have to Match?
>
> How do I translate 03, 05 and what does it mean?
>
> Thanks
>
> Stephen K. Miyasato
>
> type
> pPCT= ^pcT;
> pcT = packed record //PIBS Comm
> pc-version : array[0..5]of char; //6
> pc-version-date : array[0..7]of char ;//8
> pc-version-date : array[0..31]of char ; //32
>
> 01 pibs-comarea.
> 03 pc-version pic x(06).
> 03 pc-version-date pic x(08).
> 03 pc-program-name pic x(32).
> 03 pc-error-code pic x(03).
> 03 pc-first-call-flag pic x(01).
> 03 pc-mibs pic x(01).
> 03 pc-init-flag pic x(01).
> 03 pc-filst.
> 05 pc-file-status.
> 07 pc-fs1 pic x(01).
> 07 pc-fs2 pic x(01).
> 05 pc-fsx pic x(03).
> 03 filler pic x(01).
> 03 pc-cdate.
> 05 pc-cen pic x(02).
> 05 pc-date.
> 07 pc-year pic x(02).
> 07 pc-month pic x(02).
> 07 pc-day pic x(02).
> 03 pc-start-time pic x(04).
> 03 pc-file-cmd pic x(02).
> 03 pc-file-name pic x(24).
> 03 pc-next-acct-num pic x(10).
> 03 pc-next-pat-num pic x(10).
> 03 pc-debug pic x(02).
> 03 pc-last-closed-date pic x(08).
>