From 5f49e0ade0ac42a4e09fa5bcd38fc288d5198d6b Mon Sep 17 00:00:00 2001 From: Mark Green Date: Wed, 8 Apr 2020 17:30:10 +0100 Subject: Added COBOL. With all the current press, I think this is inevitable.. --- cobol.html.markdown | 182 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 182 insertions(+) create mode 100644 cobol.html.markdown (limited to 'cobol.html.markdown') diff --git a/cobol.html.markdown b/cobol.html.markdown new file mode 100644 index 00000000..b0ab5b6d --- /dev/null +++ b/cobol.html.markdown @@ -0,0 +1,182 @@ +--- +language: COBOL +contributors: + - ["Hyphz", "http://github.com/hyphz/"] +filename: learn.COB +--- +COBOL is a business-oriented language revised multiple times since its original design in 1960. It is claimed to still be used in over 80% of +organizations. + +``` + *COBOL. Coding like it's 1985. + + *COBOL has significant differences between legacy (COBOL-85) + *and modern (COBOL-2002 and COBOL-2014) versions. + *Legacy versions require columns 1-6 to be blank (they are used + *to store the index number of the punched card..) + *A * in column 7 means a comment. + *In legacy COBOL, a comment can only be a full line. + *Modern COBOL doesn't require fixed columns and uses *> for + *a comment, which can appear in the middle of a line. + *Legacy COBOL also imposes a limit on maximum line length. + *Keywords have to be in capitals in legacy COBOL, + *but are case insensitive in modern. + + *First, we must give our program ID. + *Identification division can include other values too, + *but they are comments only. Program-id is mandatory. + identification division. + program-id. learn. + + *Let's declare some variables. + data division. + working-storage section. + + *Variables are specified by a "picture" - how they should be + *displayed, and variable type is inferred from this. + *The "01" value is the level number which is used for building + *data structures. + 01 myname picture xxxxxxxxxx. *> A 10 character string. + 01 age picture 999. *> A number up to 3 digits. + 01 valx picture 999. *> Another number up to 3 digits. + 01 inyear picture s9(7). *> S makes number signed. + *> Brackets indicate 6 repeats of 9, + *> ie a 6 digit number (not an array). + + *Now let's write some code. + procedure division. + + main-procedure. + *> COBOL is the language that uses DISPLAY instead of PRINT. + *> Note: no full stops after commands. Only after the LAST + *> command. + display "Hello. What's your name?" + + *> Let's input a string. + *> If input too long, later characters are trimmed. + accept myname + display "Hello " myname *> We can display several things. + display "How old are you?" + + *> Let's input a number. + *> If input too long, EARLIER characters are trimmed. + accept age + + display age *> Left-padded to three chracaters with zeroes, + *> because of the defined PICTURE for age. + + *> We have two ways of doing a FOR loop. + *> Old style way: doesn't give an index. + perform age times + display "*" with no advancing *> Ie, no newline at end + end-perform. + display "." *> Output buffer isn't flushed until newline. + + *> New style way: with an index. + perform varying valx from 1 by 1 until valx > age + display valx "-" with no advancing + end-perform. + display "." + + *> If tests are still good old if tests. + if myname = "Bob" then + display "I don't like Bob." + else + display "I don't know you." + end-if + + *> There are two ways of doing subprograms and calling + *> them. + *> The simplest way: a paragraph. + perform subparagraph + + *> The complex way, with parameters and stuff. + call "eratosthenes" using age returning valx + + display "There were " valx " primes." + + stop run. + + subparagraph. *> Marks the top of an internal subprogram. + *> Shares variable score with its caller. + accept inyear from day yyyyddd. + + *> We can do math step-by-step like this... + divide 1000 into inyear. + subtract age from inyear. + + display "You were born in " inyear "." + + *> Or we can just use expressions. + compute inyear = 1970 - inyear. + + *> Note: if inyear has gone negative, its negativity will + *> not appear when printed, because we didn't include an + *> S (sign character) in the PICTURE. + if inyear >= 0 then + display "When you were " inyear ", " with no advancing + else + display inyear " years before you were born, " with no + advancing + end-if + + display "COBOL was the most popular language in the world." + . + + + identification division. + program-id. eratosthenes. + + data division. + working-storage section. + *Declare an array. + *We can declare a variable to use as an index for it at the + *same time. + 01 sieve pic 9 occurs 999 times indexed by sa, sb. + 01 pstart pic 999. + 01 counter pic 999. + + *Our parameters have to be declared in the linkage section. + linkage section. + 01 maxvalue picture 999. + + *"using" declares our actual parameter variables. + *"returning" declares the variable value returned at end. + procedure division using maxvalue returning counter. + main-procedure. + + display "Here are all the primes up to " maxvalue "." + + perform varying sa from 1 by 1 until sa > maxvalue + move 1 to sieve (sa) + end-perform + + perform varying sa from 2 by 1 until sa > maxvalue + if sieve(sa) = 1 then + compute pstart = sa + sa + perform varying sb from pstart by sa until sb > + maxvalue + move 0 to sieve(sb) + end-perform + end-if + end-perform + + initialise counter *> To zero by default for a number. + + perform varying sa from 2 by 1 until sa > maxvalue + if sieve(sa) = 1 THEN + display sa + add 1 to counter + end-if + end-perform. + + end program eratosthenes. + + end program learn. + +``` + +##Ready For More? + +* [GnuCOBOL](https://sourceforge.net/projects/open-cobol/) + -- cgit v1.2.3 From 912eca480e74a31d88d1c84ba5ab935b57541e46 Mon Sep 17 00:00:00 2001 From: Mark Green Date: Thu, 9 Apr 2020 15:20:49 +0100 Subject: Corrections and some added explanation. --- cobol.html.markdown | 119 +++++++++++++++++++++++++++------------------------- 1 file changed, 63 insertions(+), 56 deletions(-) (limited to 'cobol.html.markdown') diff --git a/cobol.html.markdown b/cobol.html.markdown index b0ab5b6d..4452bd95 100644 --- a/cobol.html.markdown +++ b/cobol.html.markdown @@ -7,12 +7,13 @@ filename: learn.COB COBOL is a business-oriented language revised multiple times since its original design in 1960. It is claimed to still be used in over 80% of organizations. -``` +```cobol *COBOL. Coding like it's 1985. + *Compiles with GnuCOBOL in OpenCobolIDE 4.7.6. *COBOL has significant differences between legacy (COBOL-85) *and modern (COBOL-2002 and COBOL-2014) versions. - *Legacy versions require columns 1-6 to be blank (they are used + *Legacy versions require columns 1-6 to be blank (they are used *to store the index number of the punched card..) *A * in column 7 means a comment. *In legacy COBOL, a comment can only be a full line. @@ -21,9 +22,9 @@ organizations. *Legacy COBOL also imposes a limit on maximum line length. *Keywords have to be in capitals in legacy COBOL, *but are case insensitive in modern. - + *First, we must give our program ID. - *Identification division can include other values too, + *Identification division can include other values too, *but they are comments only. Program-id is mandatory. identification division. program-id. learn. @@ -32,7 +33,7 @@ organizations. data division. working-storage section. - *Variables are specified by a "picture" - how they should be + *Variables are specified by a "picture" - how they should be *displayed, and variable type is inferred from this. *The "01" value is the level number which is used for building *data structures. @@ -40,9 +41,9 @@ organizations. 01 age picture 999. *> A number up to 3 digits. 01 valx picture 999. *> Another number up to 3 digits. 01 inyear picture s9(7). *> S makes number signed. - *> Brackets indicate 6 repeats of 9, + *> Brackets indicate 7 repeats of 9, *> ie a 6 digit number (not an array). - + *Now let's write some code. procedure division. @@ -64,98 +65,104 @@ organizations. display age *> Left-padded to three chracaters with zeroes, *> because of the defined PICTURE for age. - + *> We have two ways of doing a FOR loop. *> Old style way: doesn't give an index. perform age times display "*" with no advancing *> Ie, no newline at end - end-perform. + end-perform display "." *> Output buffer isn't flushed until newline. - + *> New style way: with an index. - perform varying valx from 1 by 1 until valx > age - display valx "-" with no advancing - end-perform. + perform varying valx from 1 by 1 until valx > age + display valx "-" with no advancing + end-perform display "." - + *> If tests are still good old if tests. - if myname = "Bob" then + if myname = "Bob" then display "I don't like Bob." - else - display "I don't know you." - end-if - - *> There are two ways of doing subprograms and calling + else + display "I don't know you." + end-if + + *> There are two ways of doing subprograms and calling *> them. *> The simplest way: a paragraph. perform subparagraph - + *> The complex way, with parameters and stuff. - call "eratosthenes" using age returning valx - + call "eratosthenes" using age returning valx + display "There were " valx " primes." - + stop run. subparagraph. *> Marks the top of an internal subprogram. *> Shares variable score with its caller. - accept inyear from day yyyyddd. + *> Read year from system timer. + *> Remember the whole "year 2000 crisis"? The yyyyddd + *> option was added in response to that. + accept inyear from day yyyyddd. + *> We can do math step-by-step like this... - divide 1000 into inyear. + divide 1000 into inyear. subtract age from inyear. - + display "You were born in " inyear "." - + *> Or we can just use expressions. compute inyear = 1970 - inyear. - - *> Note: if inyear has gone negative, its negativity will - *> not appear when printed, because we didn't include an - *> S (sign character) in the PICTURE. - if inyear >= 0 then + + if inyear >= 0 then display "When you were " inyear ", " with no advancing else display inyear " years before you were born, " with no advancing end-if - - display "COBOL was the most popular language in the world." - . - - + + display "COBOL was the most popular language in the world." + . *> You can put the final . on a new line if it's clearer. + + + *If we want to use a subprogram, we use literally a subprogram. + *This is the entire program layout, repeated for the + *eratosthenes subroutine. identification division. program-id. eratosthenes. data division. working-storage section. - *Declare an array. - *We can declare a variable to use as an index for it at the + *Declare an array. + *We can declare a variable to use as an index for it at the *same time. 01 sieve pic 9 occurs 999 times indexed by sa, sb. + *> Standard cobol doesn't have a boolean type. 01 pstart pic 999. 01 counter pic 999. - + *Our parameters have to be declared in the linkage section. + *Their pictures must match the values they're called with. linkage section. 01 maxvalue picture 999. - - *"using" declares our actual parameter variables. + + *"using" declares our actual parameter variables. *"returning" declares the variable value returned at end. procedure division using maxvalue returning counter. main-procedure. - + display "Here are all the primes up to " maxvalue "." - + perform varying sa from 1 by 1 until sa > maxvalue move 1 to sieve (sa) - end-perform - + end-perform + perform varying sa from 2 by 1 until sa > maxvalue - if sieve(sa) = 1 then + if sieve(sa) = 1 then compute pstart = sa + sa - perform varying sb from pstart by sa until sb > - maxvalue + perform varying sb from pstart by sa until sb > + maxvalue move 0 to sieve(sb) end-perform end-if @@ -163,17 +170,17 @@ organizations. initialise counter *> To zero by default for a number. - perform varying sa from 2 by 1 until sa > maxvalue + perform varying sa from 2 by 1 until sa > maxvalue if sieve(sa) = 1 THEN display sa add 1 to counter - end-if + end-if end-perform. - - end program eratosthenes. - + + end program eratosthenes. + end program learn. - + ``` ##Ready For More? -- cgit v1.2.3 From 2d387a2aaee2253705598ac71ea8d3711ddda7eb Mon Sep 17 00:00:00 2001 From: Hunter Coleman <35200320+HColeman1@users.noreply.github.com> Date: Sat, 2 May 2020 14:20:19 -0500 Subject: Update to cobol.html.markdown Fixed multiple errors in the COBOL tutorial. --- cobol.html.markdown | 301 ++++++++++++++++++++++++++-------------------------- 1 file changed, 149 insertions(+), 152 deletions(-) (limited to 'cobol.html.markdown') diff --git a/cobol.html.markdown b/cobol.html.markdown index 4452bd95..7c68db7b 100644 --- a/cobol.html.markdown +++ b/cobol.html.markdown @@ -8,7 +8,7 @@ COBOL is a business-oriented language revised multiple times since its original organizations. ```cobol - *COBOL. Coding like it's 1985. + *COBOL. Coding like it's 1985. *Compiles with GnuCOBOL in OpenCobolIDE 4.7.6. *COBOL has significant differences between legacy (COBOL-85) @@ -22,164 +22,161 @@ organizations. *Legacy COBOL also imposes a limit on maximum line length. *Keywords have to be in capitals in legacy COBOL, *but are case insensitive in modern. - - *First, we must give our program ID. + *Although modern COBOL allows you to use mixed-case characters + *it is still common to use all caps when writing COBOL code. + *This is what most professional COBOL developers do. + *COBOL statements end with a period. + + *COBOL code is broken up into 4 divisions. + *Those divisions, in order, are: + *IDENTIFICATION DIVSION. + *ENVIRONMENT DIVISION. + *DATA DIVISION. + *PROCEDURE DIVISION. + + *First, we must give our program an ID. *Identification division can include other values too, - *but they are comments only. Program-id is mandatory. - identification division. - program-id. learn. + *but they are comments only. Program-id is the only one that is mandatory. + IDENTIFICATION DIVISION. + PROGRAM-ID. LEARN. + AUTHOR. JOHN DOE. + DATE-WRITTEN. 05/02/2020. *Let's declare some variables. - data division. - working-storage section. - - *Variables are specified by a "picture" - how they should be - *displayed, and variable type is inferred from this. - *The "01" value is the level number which is used for building - *data structures. - 01 myname picture xxxxxxxxxx. *> A 10 character string. - 01 age picture 999. *> A number up to 3 digits. - 01 valx picture 999. *> Another number up to 3 digits. + *We do this in the WORKING-STORAGE section within the DATA DIVISION. + *Each data item (aka variable) with start with a level number, then the name of the item, + *followed by a picture clause describing the type of data that the variable will contain. + *Almost every COBOL programmer will abbreviate PICTURE as PIC. + *A is for alphabetic, X is for alphanumeric, and 9 is for numeric. + + *example: + 01 MYNAME PIC xxxxxxxxxx. *> A 10 character string. + + *But counting all those x's can lead to errors, so the above code can, and should, + *be re-written as: + 01 MYNAME PIC X(10). + + *Here are some more examples: + 01 AGE PIC 9(3). *> A number up to 3 digits. + 01 LAST_NAME PIC X(10). *> A string up to 10 characters. + + *In COBOL, multiple spaces are the same as a single space, so it is common + *to use multiple spaces to line up your code so that it is easier for other + *coders to read. 01 inyear picture s9(7). *> S makes number signed. *> Brackets indicate 7 repeats of 9, *> ie a 6 digit number (not an array). - *Now let's write some code. - procedure division. - - main-procedure. - *> COBOL is the language that uses DISPLAY instead of PRINT. - *> Note: no full stops after commands. Only after the LAST - *> command. - display "Hello. What's your name?" - - *> Let's input a string. - *> If input too long, later characters are trimmed. - accept myname - display "Hello " myname *> We can display several things. - display "How old are you?" - - *> Let's input a number. - *> If input too long, EARLIER characters are trimmed. - accept age - - display age *> Left-padded to three chracaters with zeroes, - *> because of the defined PICTURE for age. - - *> We have two ways of doing a FOR loop. - *> Old style way: doesn't give an index. - perform age times - display "*" with no advancing *> Ie, no newline at end - end-perform - display "." *> Output buffer isn't flushed until newline. - - *> New style way: with an index. - perform varying valx from 1 by 1 until valx > age - display valx "-" with no advancing - end-perform - display "." - - *> If tests are still good old if tests. - if myname = "Bob" then - display "I don't like Bob." - else - display "I don't know you." - end-if - - *> There are two ways of doing subprograms and calling - *> them. - *> The simplest way: a paragraph. - perform subparagraph - - *> The complex way, with parameters and stuff. - call "eratosthenes" using age returning valx - - display "There were " valx " primes." - - stop run. - - subparagraph. *> Marks the top of an internal subprogram. - *> Shares variable score with its caller. - - *> Read year from system timer. - *> Remember the whole "year 2000 crisis"? The yyyyddd - *> option was added in response to that. - accept inyear from day yyyyddd. - - *> We can do math step-by-step like this... - divide 1000 into inyear. - subtract age from inyear. - - display "You were born in " inyear "." - - *> Or we can just use expressions. - compute inyear = 1970 - inyear. - - if inyear >= 0 then - display "When you were " inyear ", " with no advancing - else - display inyear " years before you were born, " with no - advancing - end-if - - display "COBOL was the most popular language in the world." - . *> You can put the final . on a new line if it's clearer. - - - *If we want to use a subprogram, we use literally a subprogram. - *This is the entire program layout, repeated for the - *eratosthenes subroutine. - identification division. - program-id. eratosthenes. - - data division. - working-storage section. - *Declare an array. - *We can declare a variable to use as an index for it at the - *same time. - 01 sieve pic 9 occurs 999 times indexed by sa, sb. - *> Standard cobol doesn't have a boolean type. - 01 pstart pic 999. - 01 counter pic 999. - - *Our parameters have to be declared in the linkage section. - *Their pictures must match the values they're called with. - linkage section. - 01 maxvalue picture 999. - - *"using" declares our actual parameter variables. - *"returning" declares the variable value returned at end. - procedure division using maxvalue returning counter. - main-procedure. - - display "Here are all the primes up to " maxvalue "." - - perform varying sa from 1 by 1 until sa > maxvalue - move 1 to sieve (sa) - end-perform - - perform varying sa from 2 by 1 until sa > maxvalue - if sieve(sa) = 1 then - compute pstart = sa + sa - perform varying sb from pstart by sa until sb > - maxvalue - move 0 to sieve(sb) - end-perform - end-if - end-perform - - initialise counter *> To zero by default for a number. - - perform varying sa from 2 by 1 until sa > maxvalue - if sieve(sa) = 1 THEN - display sa - add 1 to counter - end-if - end-perform. - - end program eratosthenes. - - end program learn. + *Now let's write some code. Here is a simple, Hello World program. + IDENTIFICATION DIVISION. + PROGRAM-ID. HELLO. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 THE-MESSAGE PIC X(20). + PROCEDURE DIVSION. + DISPLAY "STARTING PROGRAM". + MOVE "HELLO WORLD" TO THE-MESSAGE. + DISPLAY THE-MESSAGE. + STOP RUN. + + *The above code will output: + *STARTING PROGRAM + *HELLO WORLD + + + + ********COBOL can perform math*************** + ADD 1 TO AGE GIVING NEW-AGE. + SUBTRACT 1 FROM COUNT. + DIVIDE VAR-1 INTO VAR-2 GIVING VAR-3. + COMPUTE TOTAL-COUNT = COUNT1 PLUS COUNT2. + + + *********PERFORM******************** + *The PERFORM keyword allows you to jump to another specified section of the code, and then to return to the next executable + *statement once the specified section of code is completed. You must write the full word, PERFORM, you cannot abbreviate it. + + IDENTIFICATION DIVISION. + PROGRAM-ID. HELLOCOBOL. + + PROCEDURE DIVISION. + FIRST-PARA. + DISPLAY 'THIS IS IN FIRST-PARA'. + PERFORM THIRD-PARA THRU FOURTH-PARA. *>skip over second-para and perfrom third and fourth + *> then after performing third and fourth, return here and continue the program until STOP RUN. + + SECOND-PARA. + DISPLAY 'THIS IS IN SECOND-PARA'. + STOP RUN. + + THIRD-PARA. + DISPLAY 'THIS IS IN THIRD-PARA'. + + FOURTH-PARA. + DISPLAY 'THIS IS IN FOURTH-PARA'. + + + *When you compile and execute the above program, it produces the following result: + THIS IS IN FIRST-PARA + THIS IS IN THIRD-PARA + THIS IS IN FOURTH-PARA + THIS IS IN SECOND-PARA + + + **********Combining variables together using STRING *********** + + *Now it is time to learn about two related COBOL verbs: string and unstring. + + *The string verb is used to concatenate, or put together, two or more stings. Unstring is used, not surprisingly, to separate a *string into two or more smaller strings. It is important that you remember to use ‘delimited by’ when you + *are using string or unstring in your program. + + IDENTIFICATION DIVISION. + PROGRAM-ID. LEARNING. + ENVIRONMENT DIVISION. + DATA DIVISION. + WORKING-STORAGE SECTION. + 01 FULL-NAME PIC X(20). + 01 FIRST-NAME PIC X(13) VALUE "BOB GIBBERISH". + 01 LAST-NAME PIC X(5) VALUE "COBB". + PROCEDURE DIVISION. + STRING FIRST-NAME DELIMITED BY SPACE + " " + LAST-NAME DELIMITED BY SIZE + INTO FULL-NAME + END-STRING. + DISPLAY "THE FULL NAME IS: "FULL-NAME. + STOP RUN. + + + *The above code will output: + + THE FULL NAME IS: BOB COBB + + + *Let’s examine it to see why. + + *First, we declared all of our variables, including the one that we are creating by the string command, in the DATA DIVISISION. + + *The action takes place down in the PROCEDURE DIVISION. We start with the STRING keyword and end with END-STRING. In between we *list what we want to combine together into the larger, master variable. + *Here, we are combining FIRST-NAME, a space, and LAST-NAME. + + *The DELIMITED BY phrase that follows FIRST-NAME and LAST-NAME tells the program how much of each variable we want to capture. + *DELIMITED BY SPACE tells the program to start at the beginning, and capture the variable until it runs into a space. + *DELIMITED BY SIZE tells the program to capture the full size of the variable. + *Since we have DELIMITED BY SPACE after FIRST-NAME, the GIBBERISH part is ignored. + + *To make this clearer, change line 10 in the above code to: + + STRING FIRST-NAME DELIMITED BY SIZE + + *and then re-run the program. This time the output is: + + THE FULL NAME IS: BOB GIBBERISH COBB + + + + + ``` -- cgit v1.2.3 From 36d86cd4d45cd8f1f13deb0a8d35b56f45754d1e Mon Sep 17 00:00:00 2001 From: Andrew Ryan Davis Date: Sun, 9 Aug 2020 14:44:38 -0700 Subject: Adjusting formatting carriage returns and some spelling --- cobol.html.markdown | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'cobol.html.markdown') diff --git a/cobol.html.markdown b/cobol.html.markdown index 7c68db7b..7b60a2e6 100644 --- a/cobol.html.markdown +++ b/cobol.html.markdown @@ -15,7 +15,7 @@ organizations. *and modern (COBOL-2002 and COBOL-2014) versions. *Legacy versions require columns 1-6 to be blank (they are used *to store the index number of the punched card..) - *A * in column 7 means a comment. + *A '*' in column 7 means a comment. *In legacy COBOL, a comment can only be a full line. *Modern COBOL doesn't require fixed columns and uses *> for *a comment, which can appear in the middle of a line. @@ -44,8 +44,9 @@ organizations. *Let's declare some variables. *We do this in the WORKING-STORAGE section within the DATA DIVISION. - *Each data item (aka variable) with start with a level number, then the name of the item, - *followed by a picture clause describing the type of data that the variable will contain. + *Each data item (aka variable) with start with a level number, + *then the name of the item, followed by a picture clause + *describing the type of data that the variable will contain. *Almost every COBOL programmer will abbreviate PICTURE as PIC. *A is for alphabetic, X is for alphanumeric, and 9 is for numeric. @@ -93,8 +94,10 @@ organizations. *********PERFORM******************** - *The PERFORM keyword allows you to jump to another specified section of the code, and then to return to the next executable - *statement once the specified section of code is completed. You must write the full word, PERFORM, you cannot abbreviate it. + *The PERFORM keyword allows you to jump to another specified section of the code, + *and then to return to the next executable + *statement once the specified section of code is completed. + *You must write the full word, PERFORM, you cannot abbreviate it. IDENTIFICATION DIVISION. PROGRAM-ID. HELLOCOBOL. @@ -102,8 +105,9 @@ organizations. PROCEDURE DIVISION. FIRST-PARA. DISPLAY 'THIS IS IN FIRST-PARA'. - PERFORM THIRD-PARA THRU FOURTH-PARA. *>skip over second-para and perfrom third and fourth - *> then after performing third and fourth, return here and continue the program until STOP RUN. + PERFORM THIRD-PARA THRU FOURTH-PARA. *>skip over second-para and perfrom 3rd & 4th + *> then after performing third and fourth, + *> return here and continue the program until STOP RUN. SECOND-PARA. DISPLAY 'THIS IS IN SECOND-PARA'. @@ -127,7 +131,10 @@ organizations. *Now it is time to learn about two related COBOL verbs: string and unstring. - *The string verb is used to concatenate, or put together, two or more stings. Unstring is used, not surprisingly, to separate a *string into two or more smaller strings. It is important that you remember to use ‘delimited by’ when you + *The string verb is used to concatenate, or put together, two or more stings. + *Unstring is used, not surprisingly, to separate a + *string into two or more smaller strings. + *It is important that you remember to use ‘delimited by’ when you *are using string or unstring in your program. IDENTIFICATION DIVISION. @@ -149,19 +156,23 @@ organizations. *The above code will output: - THE FULL NAME IS: BOB COBB *Let’s examine it to see why. - *First, we declared all of our variables, including the one that we are creating by the string command, in the DATA DIVISISION. + *First, we declared all of our variables, including the one that we are creating + *by the string command, in the DATA DIVISION. - *The action takes place down in the PROCEDURE DIVISION. We start with the STRING keyword and end with END-STRING. In between we *list what we want to combine together into the larger, master variable. + *The action takes place down in the PROCEDURE DIVISION. + *We start with the STRING keyword and end with END-STRING. In between we + *list what we want to combine together into the larger, master variable. *Here, we are combining FIRST-NAME, a space, and LAST-NAME. - *The DELIMITED BY phrase that follows FIRST-NAME and LAST-NAME tells the program how much of each variable we want to capture. - *DELIMITED BY SPACE tells the program to start at the beginning, and capture the variable until it runs into a space. + *The DELIMITED BY phrase that follows FIRST-NAME and + *LAST-NAME tells the program how much of each variable we want to capture. + *DELIMITED BY SPACE tells the program to start at the beginning, + *and capture the variable until it runs into a space. *DELIMITED BY SIZE tells the program to capture the full size of the variable. *Since we have DELIMITED BY SPACE after FIRST-NAME, the GIBBERISH part is ignored. -- cgit v1.2.3 From f19bab44fb1c8e0ecb134a18d93d043d0b60b6cd Mon Sep 17 00:00:00 2001 From: Andrew Ryan Davis Date: Sun, 9 Aug 2020 14:52:43 -0700 Subject: Fix comments not getting recognized Looks like the vertical alignment in one section was causing the comments to not be recognized --- cobol.html.markdown | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'cobol.html.markdown') diff --git a/cobol.html.markdown b/cobol.html.markdown index 7b60a2e6..7d94d8c9 100644 --- a/cobol.html.markdown +++ b/cobol.html.markdown @@ -50,21 +50,22 @@ organizations. *Almost every COBOL programmer will abbreviate PICTURE as PIC. *A is for alphabetic, X is for alphanumeric, and 9 is for numeric. - *example: - 01 MYNAME PIC xxxxxxxxxx. *> A 10 character string. + *example: + 01 MYNAME PIC xxxxxxxxxx. *> A 10 character string. - *But counting all those x's can lead to errors, so the above code can, and should, - *be re-written as: - 01 MYNAME PIC X(10). + *But counting all those x's can lead to errors, + *so the above code can, and should + *be re-written as: + 01 MYNAME PIC X(10). - *Here are some more examples: - 01 AGE PIC 9(3). *> A number up to 3 digits. - 01 LAST_NAME PIC X(10). *> A string up to 10 characters. + *Here are some more examples: + 01 AGE PIC 9(3). *> A number up to 3 digits. + 01 LAST_NAME PIC X(10). *> A string up to 10 characters. - *In COBOL, multiple spaces are the same as a single space, so it is common - *to use multiple spaces to line up your code so that it is easier for other - *coders to read. - 01 inyear picture s9(7). *> S makes number signed. + *In COBOL, multiple spaces are the same as a single space, so it is common + *to use multiple spaces to line up your code so that it is easier for other + *coders to read. + 01 inyear picture s9(7). *> S makes number signed. *> Brackets indicate 7 repeats of 9, *> ie a 6 digit number (not an array). @@ -105,7 +106,7 @@ organizations. PROCEDURE DIVISION. FIRST-PARA. DISPLAY 'THIS IS IN FIRST-PARA'. - PERFORM THIRD-PARA THRU FOURTH-PARA. *>skip over second-para and perfrom 3rd & 4th + PERFORM THIRD-PARA THRU FOURTH-PARA. *>skip second-para and perfrom 3rd & 4th *> then after performing third and fourth, *> return here and continue the program until STOP RUN. -- cgit v1.2.3 From 2c650474f60b8db2d60997c22bb1e4cc408b57b2 Mon Sep 17 00:00:00 2001 From: Lilian Besson Date: Thu, 24 Sep 2020 16:39:21 +0200 Subject: Typo in cobol tutorial : DIVSION -> DIVISION See https://duckduckgo.com/?t=canonical&q=IDENTIFICATION+DIVSION+COBOL&ia=web --- cobol.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cobol.html.markdown') diff --git a/cobol.html.markdown b/cobol.html.markdown index 7d94d8c9..22fcb6e0 100644 --- a/cobol.html.markdown +++ b/cobol.html.markdown @@ -29,7 +29,7 @@ organizations. *COBOL code is broken up into 4 divisions. *Those divisions, in order, are: - *IDENTIFICATION DIVSION. + *IDENTIFICATION DIVISION. *ENVIRONMENT DIVISION. *DATA DIVISION. *PROCEDURE DIVISION. @@ -75,7 +75,7 @@ organizations. DATA DIVISION. WORKING-STORAGE SECTION. 01 THE-MESSAGE PIC X(20). - PROCEDURE DIVSION. + PROCEDURE DIVISION. DISPLAY "STARTING PROGRAM". MOVE "HELLO WORLD" TO THE-MESSAGE. DISPLAY THE-MESSAGE. -- cgit v1.2.3 From f4138709d8fd09691b8d6161f6521502df64a99d Mon Sep 17 00:00:00 2001 From: andreytemn Date: Fri, 15 Jan 2021 11:31:38 +0100 Subject: Fix typo in data item definition (#4076) Change "with start with a level number" to "starts with a level number" --- cobol.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cobol.html.markdown') diff --git a/cobol.html.markdown b/cobol.html.markdown index 22fcb6e0..1b33f9cc 100644 --- a/cobol.html.markdown +++ b/cobol.html.markdown @@ -44,7 +44,7 @@ organizations. *Let's declare some variables. *We do this in the WORKING-STORAGE section within the DATA DIVISION. - *Each data item (aka variable) with start with a level number, + *Each data item (aka variable) starts with a level number, *then the name of the item, followed by a picture clause *describing the type of data that the variable will contain. *Almost every COBOL programmer will abbreviate PICTURE as PIC. -- cgit v1.2.3