Am 03.10.2021 um 21:46 schrieb Michael Potter:
On this URL:
https://sourceforge.net/projects/gnucobol/files/
<https://sourceforge.net/projects/gnucobol/files/>
I read this:
** file handling: include support for a callable EXTFH interface also
provided by several compilers including Micro Focus This allows users to
insert an external file handler while retaining all of the normal COBOL
I/O functions with a possible callback to libcob. To have the compiled
program call `yourfh()` for file I/O use: `cobc -fcallfh=yourfh` In turn
`yourfh()` may call `EXTFH()` to use I/O functions from GnuCOBOL. The
external file handler can also be directly invoked from COBOL, too,
using `CALL "EXTFH"`. ** Note: Not each flag contained in the FCD3 is
handled already **
Hi Michael,
yes that URL contains the NEWS file's content - I highly suggest to look
at the specific NEWS file of whatever GnuCOBOL version you use / want to
use.
Here are my questions:
1. Does yourfh() accept a single argument which is a FCD3 structure pointer?
No, it accepts the opcode as first and the FCD3 structure pointer as
second argument.
2. Is there any other documentation on this? Google is not very helpful
as it is returning answers for other cobol compilers.
EXTFH + FCD3 is actually a 'standard' way for handling file io. What you
find for other compilers should also apply to GnuCOBOL.
Actually, GnuCOBOL was already shown to be usable as EXTFH caller from
both ACUCOBOL-GT and MicroFocus.
In any case I suggest to check tests/testsuite.src/run_files.at for
samples of EXTFH in our testsuite's sources. You find both a "callfh"
example in C (it can also be a COBOL program) under "EXTFH: using ISAM
callback" and a bunch of programs that directly call the 'EXTFH' entry
point to do file io.
3. Is there a list of the fields/flags that are not handled?
Not directly, you'd have to check in the sources and map
copy/xfhfcd3.cpy against common.h FCD3 and fileio.c / fextfh.c in libcob
for the fields that are known, their values and especially: their use
(or not).
We recently had a lot of further testing and adjustments, as can also be
seen in the extended entries in the testsuite for this topic, so in any
case: testing EXTFH should use an svn checkout or nightly tarball from
GnuCOBOL (both 3.x and 4.x are nearly identical here). [that said: I
hope to push 3.2rc1 this week, so there will be an "official"
pre-release for wide testing available, too].
The main parts definitely work (organization, min/max record length,
filename, record and key definitions, all COBOL matching opcodes).
Note: as 3.x has much less "info" about the files you need to sometimes
provide "more" information, than for example from MicroFocus (like
specifying at least the number of keys correctly when doing a DELETE
FILE via EXTFH - but that is true in general - also when executing
DELETE FILE from COBOL programs).
Have a nice week,
Simon