Skip to content

Commit d35bb9b

Browse files
authored
Syntax highlighting COBOL snippets
Signed-off-by: Janos Varga <[email protected]>
1 parent 0dc9bda commit d35bb9b

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

COBOL Programming Course #2 - Advanced Topics/COBOL Programming Course #2 - Advanced Topics.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ Additionally, we cannot compare or move dynamic-length group items to any other
300300

301301
To define a dynamic length item, we can include the DYNAMIC LENGTH clause on the data description entry. Here are a couple of examples of how to indicate the clause:
302302

303-
```
303+
```COBOL
304304
01 MY-DYN PIC X DYNAMIC.
305305
01 NAME PIC X DYNAMIC LENGTH.
306306
01 DYN-PRICE PIC X DYNAMIC LIMIT 500.
@@ -321,7 +321,7 @@ There are three ways that Enterprise COBOL uses to define UTF-8 data items.
321321

322322
This type of UTF-8 data item is defined when the PICTURE clause contains one or more 'U' characters, or a single 'U' followed by a repetition factor. Take for example the piece of code below:
323323

324-
```
324+
```COBOL
325325
01 NEW-UTF-CHAR PIC U(10).
326326
```
327327

@@ -331,7 +331,7 @@ In this case, we define a fixed character-length UTF-8 data item that holds 10 U
331331

332332
Like fixed character-length, we define this by the inclusion of the 'U' character in the PICTURE clause. But now, we will add a phrase called BYTE-LENGTH. Observe the code below:
333333

334-
```
334+
```COBOL
335335
01 NEW-UTF-BYTE PIC U BYTE-LENGTH 10.
336336
```
337337

@@ -341,7 +341,7 @@ In this case, we define a fixed byte-length UTF-8 data item that holds 10 bytes
341341

342342
Lastly, we have the dynamic-length UTF-8 data items. This is defined when we have a PICTURE clause with the 'U' character and the DYNAMIC LENGTH clause. Observe the code below:
343343

344-
```
344+
```COBOL
345345
01 NEW-UTF-DYN PIC U DYNAMIC LIMIT 10.
346346
```
347347

@@ -409,7 +409,7 @@ Each middleware has unique reserved words available to Enterprise COBOL.
409409

410410
Enterprise COBOL unique API reserved words are in Example 1.
411411

412-
```
412+
```COBOL
413413
EXEC SQL
414414
EXEC CICS
415415
CALL 'MQ...'
@@ -422,7 +422,7 @@ Each of the above COBOL API's enable the program to communcate with Db2, CICS, M
422422
### COBOL EXEC SQL
423423
SQL, Structured Query Language, is the documented standard for communicating will all relational databases. Enterprise COBOL is capable of including Db2 for z/OS SQL. A few simple COBOL EXEC SQL reserved words are shown in Example 2.
424424

425-
```
425+
```COBOL
426426
WORKING-STORAGE SECTION.
427427
*****************************************************
428428
* SQL INCLUDE FOR SQLCA *
@@ -469,7 +469,7 @@ The fields in the Db2 table record were defined using CREATE TABLE SQL. The EXE
469469

470470
Observe ":CUSTOMER-RECORD" in the EXEC SQL FETCH statement. A colon (:) precedes COBOL program defined variables that are used in SQL statements so that Db2 can distinguish a variable name from a column name. Example 3. shows the COBOL program data items describing the COBOL program variable names.
471471

472-
```
472+
```COBOL
473473
*****************************************************
474474
* STRUCTURE FOR CUSTOMER RECORD *
475475
*****************************************************
@@ -718,7 +718,7 @@ Furthermore, we can code more than one PROCESS or CBL statement. If we do so, th
718718

719719
Take a look at the following example:
720720

721-
```
721+
```COBOL
722722
PROCESS LIST,MAP.
723723
*-----------------------
724724
IDENTIFICATION DIVISION.
@@ -872,7 +872,7 @@ Recommended file organizations:
872872
- Indexed organization with sequential access
873873

874874
The recommended pattern for input:
875-
```
875+
```COBOL
876876
OPEN INPUT fn
877877
...
878878
READ fn INTO local-storage-item
@@ -883,7 +883,7 @@ The recommended pattern for input:
883883
```
884884

885885
The recommended pattern for output:
886-
```
886+
```COBOL
887887
OPEN OUTPUT fn
888888
...
889889
* Construct output record in local-storage item.
@@ -967,7 +967,7 @@ We can also use top-down programming constructs. In simpler term, we would work
967967

968968
Before we continue, let us talk a bit about in-line and out-of-line PERFORM statements. Chances are you have seen them without realizing what they are. Take a look at the example below:
969969

970-
```
970+
```COBOL
971971
PERFORM 010-INITIALIZE
972972
PERFORM UNTIL END-OF-FILE
973973
READ FILE-DATA INTO WS-DATA
@@ -991,15 +991,15 @@ It is also suggested to avoid the use of the following constructs:
991991

992992
We can also factor expressions in our programs to eliminate unnecessary computation. Take a look at the examples below. The first block of code is more efficient than the second block of code.
993993

994-
```
994+
```COBOL
995995
MOVE ZERO TO TOTAL
996996
PERFORM VARYING I FROM 1 BY 1 UNTIL I = 10
997997
COMPUTE TOTAL = TOTAL + ITEM(I)
998998
END-PERFORM
999999
COMPUTE TOTAL = TOTAL * DISCOUNT
10001000
```
10011001

1002-
```
1002+
```COBOL
10031003
MOVE ZERO TO TOTAL
10041004
PERFORM VARYING I FROM 1 BY 1 UNTIL I = 10
10051005
COMPUTE TOTAL = TOTAL + ITEM(I) * DISCOUNT
@@ -1044,7 +1044,7 @@ We can also define integer items as BINARY or PACKED-DECIMAL with nine or fewer
10441044

10451045
We can use floating point for exponentiations for large exponents to achieve faster and more accurate results. For example, the first statement below is computed more quickly and accurately compared with the second statement:
10461046

1047-
```
1047+
```COBOL
10481048
COMPUTE FIXED-POINT1 = FIXED-POINT2 ** 100000.E+00
10491049
COMPUTE FIXED-POINT1 = FIXED-POINT2 ** 100000
10501050
```

0 commit comments

Comments
 (0)