Quick actions

cmd+k|ctrl+k

Navigation

Languages

COBOL file locking

Snippet info

Language

Cobol

Visibility

public

Author

rightfold

Created

2018-05-10T19:47:29Z

Updated

2018-05-10T19:53:59Z

      *It appears like the file is indeed locked when opening it, but this lock
      *is ignored by /cat/! It is not ignored when opened by another COBOL
      *program, though.
      *
      *If viewing on glot.io, do checkout the run settings tab, which has a
      *custom command for running multiple concurrent instances of this
      *program.

       IDENTIFICATION DIVISION.
       PROGRAM-ID. example.

       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
       SELECT OPTIONAL fd-example
           ASSIGN TO 'example.txt'
           ACCESS IS SEQUENTIAL
           ORGANIZATION IS RECORD SEQUENTIAL.

       DATA DIVISION.
       FILE SECTION.
       FD fd-example.
       01 fs-example                   PIC X(11).

       PROCEDURE DIVISION.
           MOVE 'HELLO WORLD' TO fs-example

           OPEN EXTEND fd-example
           WRITE fs-example
           CALL 'C$SLEEP' USING 2
           CLOSE fd-example

           EXIT PROGRAM
           .
INFO