For 32-bit Windows users, the ACUCOBOL-GT runtime is available in a DLL file.
To call the 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
Declare Function AcuGetCallError Lib"wrun32.dll" () As Integer Declare Sub AcuCancel Lib "wrun32.dll" (ByVal name As String)
After you add the declarations, you 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:
returnValue = AcuInitialize("-c myconfig -le myerrors")
"AcuInitialize" returns a value of "0" on success and "-1" on failure. You can safely 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 appears when you actually call a COBOL program.
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" calls 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|
|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|
|27||Program contains object code for a different processor|
|28||Incorrect serial number|