bug-gnucobol
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

The next question


From: James Smith
Subject: The next question
Date: Sat, 21 Mar 2020 16:59:11 -0600

Brian Tiffin kindly showed me the error of my compile script. All OK now. Each module now compiles properly. Thank you, Brian. Now I would like to learn about CALLs. Here is my saga to date:


I am trying to master Dynamic versus Static CALLs within GnuCOBOL.

My compile script, below, is used for two situations, static and dynamic. I comment out the appropriate lines as needed to test each scenario.

My CALLing program, source below, also has a variety of conditions that I comment out as needed to test the next variation.

The CALLed program, source below, OPENs EXTEND a log file and writes two lines to it when it executes. This is the only evidence that it ran.

Each compile command compiles clean. The result of each test run is noted against the actual CALL that generated that result in the source code. Currently all are commented out. Please believe me, I did run each instance. The execution sequence is to set up the calls in the source, set up the compile script to match that, run the compile, verify that it is clean and then run the result with "./calls" and look into the log file.

It is evident that I can get the CALL to work. It is also evident that I do not understand what is wrong with the other attempts. I want to understand where I have gone wrong. Thank you for your assistance. I am willing to do whatever else may be needed to make this more clear or to cover instances of which I have not thought.

#####################################################################
This is the compile script.
#!/bin/bash
#! /home/james/cobolsandbox/contributions/compile-calls.sh
   rm -v calls
#! rm -v called  #! Leave this behind to test some Static calls

echo "*>--------------------------------------------------------"
#! Static
#! This method works
cobc -free -Xref -v -W -T calls.lst   -x -o calls     calls.cbl called.cbl

#! Dynamic
#! This method fails
#! libcob: module 'called' not found
#!cobc -free -Xref -v -W -T calls.lst   -x -o calls     calls.cbl
#!echo "*>--------------------------------------------------------"
#!cobc -free -Xref -v -W -T called.lst  -x -o called    called.cbl

echo "*>--------------------------------------------------------"

ls -alF call*
#####################################################################
This is the source of the program that CALLs
*>      $ SET SOURCEFORMAT "FREE"
*>------------------------------------------------
IDENTIFICATION DIVISION.
PROGRAM-ID.  calls.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.

REPOSITORY.
    FUNCTION ALL INTRINSIC.

INPUT-OUTPUT SECTION.
FILE-CONTROL.

*>------------------------------------------------
DATA DIVISION.
FILE SECTION.

*>------------------------------------------------
WORKING-STORAGE SECTION.
*>------------------------------------------------
01  WS-Pgm-To-Call-Full.
    05                        PIC X(39) VALUE
        "/home/james/cobolsandbox/contributions/".
    05  WS-Pgm-To-Call        PIC X(10) VALUE "called    ".
01  WS-Pgm-To-Call-NoPath     PIC X(10) VALUE "called  ".
01  WS-Pgm-To-Call-Short      PIC X(10) VALUE "./called  ".

*>------------------------------------------------
PROCEDURE DIVISION.
*>------------------------------------------------
000-Main.

*> Static
*>    CALL "./called"                           END-CALL.  *> THIS WORKS
*>    CALL "called"                             END-CALL.  *> THIS WORKS
*>    CALL WS-Pgm-To-Call-Full                  END-CALL.  *> THIS WORKS
*>    CALL WS-Pgm-To-Call-Short                 END-CALL.  *> THIS WORKS
*>    CALL WS-Pgm-To-Call-NoPath                END-CALL.  *> THIS WORKS
*>    CALL "SYSTEM" USING WS-Pgm-To-Call-Short  END-CALL.  *> THIS WORKS IF called exists in current directory!
*>    CALL "SYSTEM" USING WS-Pgm-To-Call-Short  END-CALL.  *> sh: 1: ./called: not found
*>    CALL "SYSTEM" USING WS-Pgm-To-Call-NoPath END-CALL.  *> sh: 1: called: not found
*>    CALL "SYSTEM" USING WS-Pgm-To-Call        END-CALL.  *> sh: 1: called: not found
*>    CALL "SYSTEM" USING "called"              END-CALL.  *> sh: 1: called: not found

*> Dynamic
*>    CALL "./called"                           END-CALL.  *> libcob: module 'called' not found
*>    CALL "called"                             END-CALL.  *> libcob: module 'called' not found
*>    CALL WS-Pgm-To-Call-Full                  END-CALL.  *> libcob: module 'called' not found
*>    CALL WS-Pgm-To-Call-Short                 END-CALL.  *> libcob: module 'called' not found
*>    CALL WS-Pgm-To-Call-NoPath                END-CALL.  *> libcob: module 'called' not found
*>    CALL "SYSTEM" USING WS-Pgm-To-Call        END-CALL.  *> sh: 1: called: not found
*>    CALL "SYSTEM" USING WS-Pgm-To-Call-NoPath END-CALL.  *> sh: 1: called: not found
*>    CALL "SYSTEM" USING WS-Pgm-To-Call-Short  END-CALL.  *> THIS WORKS
*>    CALL "SYSTEM" USING "called"              END-CALL.  *> sh: 1: called: not found

GOBACK.

*>------------------------------------------------
END PROGRAM calls.
#####################################################################
This is the source of the program to be CALLed
*>>      $ SET SOURCEFORMAT "FREE"
IDENTIFICATION DIVISION.
PROGRAM-ID.  called.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.

REPOSITORY.
    FUNCTION ALL INTRINSIC.

INPUT-OUTPUT SECTION.
FILE-CONTROL.
    SELECT Log-File
        ASSIGN DISK "./logs/main.log"
        FILE STATUS IS WS-StatusLOG
        ORGANIZATION LINE SEQUENTIAL
        SHARING ALL.

DATA DIVISION.
FILE SECTION.
FD  Log-File.
01  Log-File-Printline          PIC X(80).

WORKING-STORAGE SECTION.
01  WS-Pgm-ID                   PIC X(10) VALUE "called".

01  WS-StatusLOG                PIC X(02).

01  WS-Log-Line-1.
    05  Pgm-ID                  PIC X(10) VALUE SPACE.
    05                          PIC X(01) VALUE SPACE.
    05  Msg                     PIC X(49) VALUE SPACE.

PROCEDURE DIVISION.
000-Main.
    MOVE WS-Pgm-ID TO Pgm-ID      OF WS-Log-Line-1.
    MOVE "Begin job" TO Msg       OF WS-Log-Line-1.
    OPEN EXTEND Log-file.
    WRITE Log-File-Printline
      FROM WS-Log-Line-1
      AFTER ADVANCING 1
    END-WRITE.

    MOVE "End job"   TO Msg       OF WS-Log-Line-1.
    WRITE Log-File-Printline
      FROM WS-Log-Line-1
      AFTER ADVANCING 1
    END-WRITE.
    CLOSE Log-File.
    GOBACK.

END PROGRAM called.


--

In service
James Smith
916-955-5871

http://www.SJHS65.com/

System analysis is the process of finding exactly the right wrench to pound in the correct screw.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]