次の例は、RunUnit 内から CBL_MANAGED_SESSION_GET_USERDATA と CBL_MANAGED_SESSION_SET_USERDATA を使用する例を示しています。
ライブラリ ルーチンを利用する COBOL プログラム:
program-id. "GetUserDataExample".
procedure division.
*> retrieves a user data object called message from the
*> current rununit
declare msg as string
call "CBL_MANAGED_SESSION_GET_USERDATA" using
by value "message"
returning msg
end-call.
*> creates a new user data object that contains the
*> original object "OK"
set msg to msg & " - OK"
call "CBL_MANAGED_SESSION_SET_USERDATA" using
by value "reply"
by value msg
end-call.
goback.
および RunUnit 内から COBOL プログラムを呼び出す JavaC# プログラム:
using System;
using MicroFocus.COBOL.RuntimeServices;
class MainClass {
public static void Main(string[] args) {
RunUnit ru = new RunUnit();
try
{
ru.SetUserData("message","PASS: CBL_MANAGED_SESSION_GET_USER_DATA");
ru.Call("C");
Console.WriteLine(ru.GetUserData("reply"));
}
finally
{
ru.StopRun();
}
}
}
import com.microfocus.cobol.runtimeservices.*;
class demoUserData {
public static void main(String[] args) {
RunUnit ru = new RunUnit();
try
{
ru.SetUserData("message","PASS: CBL_MANAGED_SESSION_GET_USER_DATA");
ru.Call("GetUserDataExample");
System.out.println(ru.GetUserData("reply"));
}
finally
{
ru.StopRun();
}
}
}