Author: admin

  • Looping

    We will now cover some of the looping logic in cobol. One thing I’ll mention before we get into it: We can name parts of the procedure division; these named parts, called paragraphs, can be used kind of similarly to functions or named lambda functions in python. In cobol a paragraph can contain many sentences/statements.…

  • String Handling

    String handling in cobol is very verbose and requires a lot of typing. Let’s try it. Tallying all or just specific characters is pretty clear. The replacing keyword is also pretty clear, it replaces specified data in the string with some other data. Whats really worth digging into here is the string concatenation and the…

  • Conditionals

    In this section we will look at if/else statements and switch statements. All this should be familiar to you if you have done any programming. You have your standard if/else, not/and/or operators, type comparisons, and switch statements. The only thing that might be a little weird are the pre-defined statements. What has essentially happened here…

  • Common Verbs

    In cobol a verb is a keyword that does something (docs). We will cover the compute, divide, multiply, subtract, add, move, and initialize verbs. These are verbs you will use often in cobol programming to calculate, say the result of a business transaction. compute — can be used to do arithmetic and store the result…

  • Declaring Variables

    I will write a script below that explains how to declare and print variables. We will declare several variables in the data division (FIRST-VAR, SECOND-VAR, etc) and then print them in the procedure division using DISPLAY. PIC stands for picture (not sure why it is called this) and it is a keyword we use to…

  • Understanding the Program Structure

    First and foremost to comment in cobol use the *> characters. In a cobol program there are several possible divisions. A division is just a way to break up the program into areas responsible for different things. So IDENTIFICATION DIVISION is responsible for identifying the program (docs). We are only going to use the PROGRAM-ID keyword, giving our program a name,…

  • How to Compile and run

    Create the runable bytecode file with the instructions below. This transpiles our COBOL program called ‘hello.cbl’ to C then it takes the C and produces an executable object/bytecode file called ‘hello’. Compile and then run with: Should output: WILLKOMMEN

  • How to write a Program

    We will write a simple program in cobol called ‘hello.cbl’. There are a lot of strange keywords in cobol. I will explain them after compilation.

  • How to Install the GnuCobol compiler

    This compiler transpiles COBOL to C bytecode that can run on your linux bash command line. Not all the features of COBOL are supported but most are. Run (to install):

  • Why does COBOL have a bad reputation?

    As you can see from this little example, COBOL is not like your normal programming language. You can’t write a compiler or a kernel module in COBOL, and the syntax is not what we’ve grown to expect. But then consider another common domain-specific language: SQL. The syntax is kind of weird, and the semantics depend…