Skip to content

Instantly share code, notes, and snippets.

@juliarose
Last active April 16, 2024 17:39
Show Gist options
  • Save juliarose/fd9ce0e3c8e4a705e0a2cb82e3e48ea5 to your computer and use it in GitHub Desktop.
Save juliarose/fd9ce0e3c8e4a705e0a2cb82e3e48ea5 to your computer and use it in GitHub Desktop.
A simple COBOL template.
000100*AAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBIIIIIIII
000150*Format lines:
000151* awk -i inplace '{printf("%04d00%s\n", NR, substr($0,7,120)) }' main.cbl
000160*Compile and run:
000161* cobc -x main.cbl && ./main
000200 IDENTIFICATION DIVISION.
000400 PROGRAM-ID. hello.
000500 AUTHOR. JULIA.
000600 DATE-WRITTEN. 2024-04-14.
000700 DATE-COMPILED. 2024-04-14.
000800 REMARKS. This is a pretty good COBOL program.
000900*
001000 ENVIRONMENT DIVISION.
001100 CONFIGURATION SECTION.
001200 SOURCE-COMPUTER. Ubuntu_Linux_x64_20_04_6_LTS.
001300 OBJECT-COMPUTER. Ubuntu_Linux_x64_20_04_6_LTS.
001400 INPUT-OUTPUT SECTION.
001500 FILE-CONTROL.
001600 I-O-CONTROL.
001700*
001800 DATA DIVISION.
001900 FILE SECTION.
002000 WORKING-STORAGE SECTION.
002099*Local storage is re-allocated each time a program is called.
002100 LOCAL-STORAGE SECTION.
002200 LINKAGE SECTION.
002298*Report and screen section not available with IBM Cobol x86
002299*Commented to avoid compilation warning
002300* REPORT SECTION.
002400 SCREEN SECTION.
002500*
002600 PROCEDURE DIVISION.
002600 DISPLAY "Hello, world!".
005000 STOP RUN.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment