Menu

PROCEDURE DIVISION USING in main program

J McNamara
2025-01-02
2025-01-03
  • J McNamara

    J McNamara - 2025-01-02
    IDENTIFICATION DIVISION.
     PROGRAM-ID. subcob.
     DATA DIVISION.
     WORKING-STORAGE SECTION.
     01 LN-ARG2 PIC 99.
     LINKAGE SECTION.
     01 Arg1 PIC X(7).
     01 Arg2 PIC X ANY LENGTH.
     01 Arg3 USAGE BINARY-INT.
     PROCEDURE DIVISION USING BY VALUE Arg1, BY REFERENCE Arg2, Arg3.
     000-Main.
     DISPLAY 'Starting cobsub.cbl'
     MOVE LENGTH OF ARG2 TO LN-ARG2.
     DISPLAY 'Arg1=' Arg1 '.'
     DISPLAY 'Arg2=' Arg2 '. Len:' LN-ARG2
     DISPLAY 'Arg3=' Arg3 '.'
     MOVE 'X' TO Arg1 (1:1)
     MOVE 'Y' TO Arg2 (1:1)
     MOVE 987654321 TO Arg3
     MOVE 2 TO RETURN-CODE
     GOBACK. 
    

    < above taken from Ron Norman's guide >

    i think i tried this and got errors. it said you cant use using in procedure when expecting an executable.

    my compile line would look like this..

    g++ -shared -o myptr.dll testabc.c -Wl,--out-implib,myptr.lib
    RESET
    cd ~/cobjapi-SWING/examples_simple
    pwd
    # Try to remove dialog.o, if it exists
    if [ -f "dialog.o" ]; then
        rm dialog.o
        if [ $? -ne 0 ]; then
            echo "Failed to remove dialog.o, but continuing script."
        fi
    else
        echo "dialog.o does not exist, skipping removal."
    fi
    # Try to remove dialog.o, if it exists
    if [ -f "dialog.cbsql" ]; then
        rm dialog.cbsql
        if [ $? -ne 0 ]; then
            echo "Failed to remove dialog.o, but continuing script."
        fi
    else
        echo "dialog.o does not exist, skipping removal."
    fi
    echo 'gixpp'
    gixpp -e -S -i dialog.cbl -o dialog.cbsql
    echo 'gixsql'
    gixsql dialog.cbl dialog.cbsql -S -I.
    echo 'cobc'
    cobc -x -v -fixed dialog.cbsql cobjapi.o japilib.o imageio.o fileselect.o  \
     -I. -L"c:\msys64\mingw64\bin" -L"c:\msys64\mingw64\lib" -L"c:\msys64\opt\gixsql\lib"  -L. -lws2_32 \
     -ljapi \
     -lgixsql \
     -lstdc++ \
     -lcob \
     -lmyptr
    

    so is this telling me i need a DLL to use using in the procedure section instead of my
    script the way it is above ? I could maybe transform it to output a DLL if that would help.

    this bug is also filed- [bugs:#641]

    I got the calling from cobol to C down a little (need to practice more) but am wondering how to go in the reverse direction. So I ask because it doesn't seem to work in Ron's guide.

    Is there anyway to make this work that is concise like Ron's guide [the bug fix and change to the guide if that is what is going on]?

    There is NO HURRY. I am just trying to get notes in place to handle this when it comes up.

    thanks,
    jim

     

    Related

    Bugs: #641


    Last edit: Simon Sobisch 2025-01-03
  • Simon Sobisch

    Simon Sobisch - 2025-01-03

    That should work, as long as you don't compile the specific program to an executable (-x may only be used for the single compilation of the main object file and binary).

     

Anonymous
Anonymous

Add attachments
Cancel