![]() If we delimit by SPACE we are saying to take the input string up to the first space and omit the rest. If we delimit by SIZE we are telling cobol to add the entire input string to the final string. In the STRING statement we pass in the original strings WS-STR2, WS-STR3, WS-STR1 and we use a DELIMITED BY to tell the string statement how to combine them. Whats really worth digging into here is the string concatenation and the splitting. The replacing keyword is also pretty clear, it replaces specified data in the string with some other data. Tallying all or just specific characters is pretty clear. These are verbs you will use often in cobol programming to calculate, say the result of a business transaction. We will cover the compute, divide, multiply, subtract, add, move, and initialize verbs. In cobol a verb is a keyword that does something ( docs). Here is another data declaration resource. You may have noticed that I do this above in the subgroup. Below are the functions and what each data type above corresponds to.Ī final example: 01 CAT-PEOPLE PIC X(15) VALUE create a variable called CAT-PEOPLE with space for 15 alphanumeric elements that only actually fills out 8 of them. 01 is for top level variables, 05 is group level variables under some other variable. These numbers are called level numbers and indicate to cobol what kind of variable we are declaring. ![]() You may also notice the 01 values before each declaration, and the 05 value before sub variables. Above we define many variables and then print them out. So 9(3) would correspond to laying aside enough room in memory for storing a number with 3 values. We use functions of the form type(elements). PIC stands for picture (not sure why it is called this) and it is a keyword we use to define a variable. We will declare several variables in the data division (FIRST-VAR, SECOND-VAR, etc) and then print them in the procedure division using DISPLAY. I will write a script below that explains how to declare and print variables. Ok so now that we have gotten through the basics of the program structure let’s write some programs. Below I may refer to anything that ends with a period as a statement. This is how you end a sentence (a series of one or more statements) in cobol. You may notice the dot/period at the end of some lines. Also: EVERYTHING IN COBOL IS CAPITALIZED SO ITS OFTEN EASIER TO TYPE WITH CAPSLOCK ON. This is not a mistake the compiler expects this and on a mainframe these 6 spaces would be used for line numbers. You will also notice 6 spaces on the left of all my programs. The STOP RUN sentence (sentence=one or more ‘statements’ that ends with a ‘.’) exits the program (like sys.exit() in python). It actually runs our code and can access anything defined in the data division ( docs). ![]() The PROCEDURE DIVISION is like the main function of our program. The DATA DIVISION is a place where we can declare variables we want to use in our program, we will use the WORKING-STORAGE keyword ( docs). We are only going to use the PROGRAM-ID keyword, giving our program a name, to keep it simple. So IDENTIFICATION DIVISION is responsible for identifying the program ( docs). A division is just a way to break up the program into areas responsible for different things. In a cobol program there are several possible divisions. WILLKOMMEN Understanding the Program Structureįirst and foremost to comment in cobol use the *> characters. This transpiles our COBOL program called ‘hello.cbl’ to C then it takes the C and produces an executable object/bytecode file called ‘hello’. Create the runable bytecode file with the instructions below.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |