29 October 2023

This is too good not to share (Enterprise Cobolscript).

 Saved from my old blog c/o the Internet Archive:


"Enterprise COBOL supports Java™-based object-oriented syntax to facilitate the interoperation of COBOL and Java programs."

This is just too good not to share
DATA DIVISION.
  WORKING-STORAGE SECTION.
    01 CURR-ARG-COUNT PIC 9(9) BINARY VALUE ZERO.
  LINKAGE SECTION.
    01 ARG-COUNT PIC 9(9)BINARY.
    01 ARG-LENGTH-LIST.
       05 ARG-LENGTH-ADDR POINTER OCCURS 1 TO 99999 DEPENDING ON CURR-ARG-COUNT.
    01 ARG-LIST.
       05 ARG-ADDR POINTER OCCURS 1 TO 99999 DEPENDING ON CURR-ARG-COUNT.
    01 ARG-LENGTH PIC 9(9) BINARY.
    01 ARG PIC X(65536).
PROCEDURE DIVISION USING ARG-COUNT ARG-LENGTH-LIST ARG-LIST.
That's Enterprise COBOL for main(int ac, char *av[]). But you ain't seen nothin' yet... you thought ADD ONE TO COBOL GIVING COBOL was a joke:
CBL DLL,THREAD,PGMNAME(LONGMIXED)
IDENTIFICATION   DIVISION.
CLASS-ID.
  ACCOUNT  INHERITS  BASE.
*
ENVIRONMENT   DIVISION.
  CONFIGURATION   SECTION.
    REPOSITORY.
      CLASS   BASE     IS  "java.lang.OBJECT"
      CLASS   ACCOUNT  IS  "Account".
*
IDENTIFICATION   DIVISION.
  FACTORY.
    DATA   DIVISION.
      WORKING-STORAGE   SECTION.
        01   NUMBER-OF-ACCOUNTS  PIC  9(6)  VALUE  ZERO.
*   ...
*
  OBJECT.
    DATA   DIVISION.
      WORKING-STORAGE   SECTION.
        01   ACCOUNTNUMBER   PIC  9(6).
        01   ACCOUNTBALANCE  PIC  S9(9)  VALUE  ZERO.
*
    PROCEDURE   DIVISION.
*
      IDENTIFICATION   DIVISION.
        METHOD-ID.   "getBalance".
      DATA   DIVISION.
         LINKAGE   SECTION.
           01   OUTBALANCE  PIC  S9(9)  BINARY.
 *
      PROCEDURE   DIVISION  RETURNING  OUTBALANCE.
         MOVE   ACCOUNTBALANCE  TO  OUTBALANCE.
      END METHOD "getBalance".
* ...
*
  END   OBJECT.
*
END CLASS ACCOUNT.


No comments:

Post a Comment