In order to call the ACUCOBOL-GT Runtime DLL from another programming language, you must add certain declarations to the source program. This example shows what you would use in Visual Basic:
Declare Function AcuInitialize Lib "wrun32.dll" _ (Optional ByVal cmdLine As String) As Integer Declare Sub AcuShutdown Lib "wrun32.dll" () Declare Function AcuCall Lib "wrun32.dll" _ (ByVal name As String, _ Optional param1, _ Optional param2, _ Optional param3, _ Optional param4, _ Optional param5, _ Optional param6, _ Optional param7, _ Optional param8, _ Optional param9, _ Optional param10, _ Optional param11, _ Optional param12, _ Optional param13, _ Optional param14) As Integer Declare Function AcuCall50 Lib "wrun32.dll" _ (ByVal name As String, _ Optional param1, _ ... Optional param50) As Integer
Then you must initialize the runtime, call the COBOL program(s) passing the program name and parameters, and shut down when you are finished. For example, in Visual Basic you would perform the following steps:
1. Call AcuInitialize to pass the runtime's command line options. For example:
returnValue = AcuInitialize("-c myconfig -le myerrors")
AcuInitialize returns a value of "0" on success and "-1" on failure. It is safe to call AcuInitialize multiple times. The command line from the first call is used and is ignored on subsequent calls.
You may use the runtime "-d" option to debug your ACUCOBOL-GT program. Specify "-d" in the command line to AcuInitialize, and the debugger window will appear when you actually call a COBOL program.
2. Then call AcuCall or AcuCall50, passing the program name and parameters. For example, to call the program VB-TEST with AcuCall, enter:
returnValue = AcuCall("vbtest.acu", testNum, testStr, testLongNum, testFloat)
AcuCall returns "0" on success and "-1" on failure. If AcuInitialize hasn't been called yet, AcuCall will call it, passing an empty command line. If AcuCall returns "-1", you may call AcuGetCallError to get the error code. The error codes are as follows:
-4
| AcuCall (or AcuCall50) has been called in multiple threads
|
-3
| AcuInitialize failed. (AcuInitialize cannot be called after AcuShutdown in a
single process.)
|
1
| Program missing or inaccessible
|
2
| Not a COBOL program
|
3
| Corrupted program
|
4
| Inadequate memory available
|
5
| Unsupported version of object code
|
6
| Program already in use
|
7
| Too many external segments
|
25
| Connection refused - perhaps AcuConnect is not running
|
AcuCancel("vbtest.acu")