19.2.3 引数の受け渡し
Visual BasicプログラムからCOBOLプログラムへ引数を渡す方法を,次に示します。
- 〈この項の構成〉
(1) 整数型,ユーザ定義型のデータ項目を渡す例
- Visual Basicプログラム
Private Declare Sub COBSUB Lib "SAMPLE1" _ Alias "_SAMPLE1@12" _ (ByVal a As Integer, _ ByRef a As Integer, _ ByRef a As UserDef) Private Declare Sub CBLGINT Lib "CBL85RT" Alias "_CBLGINT@0" () Private Declare Sub CBLEND Lib "CBL85RT" Alias "_CBLEND@0" () Dim PARM1 As Integer Dim PARM2 As Integer Private Type UserDef U_INT1 As Integer U_INT2 As Integer End Type Dim PARM3 As UserDef Private Sub Command1_Click() : Call SAMPLE1(PARM1, PARM2, PARM3) : End Sub Private Sub Form_Load() : Call CBLGINT : End Sub Private Sub Form_Unload(Cancel As Integer) : Call CBLEND : End Sub
- COBOLプログラム
IDENTIFICATION DIVISION. PROGRAM-ID. SAMPLE1. ENVIRONMENT DIVISION. DATA DIVISION. LINKAGE SECTION. 01 L-PARM1 PIC S9(04) USAGE COMP. 01 L-PARM2 PIC S9(04) USAGE COMP. 01 L-PARM3. 02 U-INT1 PIC S9(04) USAGE COMP. 02 U-INT2 PIC S9(04) USAGE COMP. PROCEDURE DIVISION USING BY VALUE L-PARM1 BY REFERENCE L-PARM2 BY REFERENCE L-PARM3. ADD 100 TO L-PARM1. ADD 100 TO L-PARM2. ADD 100 TO U-INT1. ADD 100 TO U-INT2. EXIT PROGRAM.
-
Visual BasicプログラムからCOBOLプログラムに引数が値渡しで渡された場合,COBOLプログラム内で受け取る引数には,BY VALUEを指定しなければなりません。また,参照渡しで渡される場合,COBOLプログラム内で受け取る引数には,BY REFERENCEを指定しなければなりません。
-
COBOLプログラムがVisual Basicプログラムから数字項目を受け取る場合は,内部・外部10進項目,内部・外部浮動小数点項目などの数字属性を意識する必要があります。