Microsoft KB Archive/37904

How to Use Segmentation in COBOL 2.x; prog.INT, prog.050

PSS ID Number: Q37904 Article last modified on 04-20-1993

2.00 2.10 2.20 MS-DOS

Summary: The segmentation facility of Microsoft COBOL Versions 2.x allows programs that are larger that physical memory to be compiled and executed. When you use segmentation, the entire PROCEDURE DIVISION must be written in sections. Section numbers 49 and lower are fixed segments, while section numbers 50 and higher are independent segments. A PERFORM statement in a fixed segment (section numbers 0 through 49) may have its target in either a fixed or independent segment. However, a PERFORM statement in an independent (section numbers greater than 50) segment may only target a fixed segment or a paragraph within its own segment.

More Information: The program example below demonstrates the proper syntax to set up segmentation. When this code is compiled, the compiler generates the following five separate disk files: SEGMENT.INT SEGMENT.050 SEGMENT.051 SEGMENT.052 SEGMENT.053 The following is a code example:

identification division. program-id. SEGMENT. * * Example:  DEMONSTRATES USING SEGMENTATION IN  *           COBOL 2.0, 2.1, 2.2 *  environment division. data division. working-storage section. 01 mov-value  pic 9 value 1. 01 tble. 05 tbl-ent occurs 5 times pic 9. * INCLUDES THE INKEY TO PROVIDE A BREAK TO ALLOW A * PERSON TO NOTICE THAT THE DISK IS ACCESSED 01 INKEY PIC X.  procedure division. A SECTION 01. para1. perform loop-it until mov-value = 6. perform SEE5. ACCEPT INKEY. perform SEE1. ACCEPT INKEY. PERFORM SEE2. ACCEPT INKEY. PERFORM SEE3. ACCEPT INKEY. PERFORM SEE4. ACCEPT INKEY. PERFORM SEE5. stop run. B SECTION 02. loop-it. move mov-value to tbl-ent (mov-value). add 1 to mov-value. C SECTION 49. SEE1. exhibit tbl-ent (1). * ALL SECTIONS GREATER THAN 49 ARE SEPARATELY * GENERATED OVERLAYS -- AND WILL BE SEPARATE * DISK FILES. G SECTION 50. SEE2. exhibit tbl-ent (2). D SECTION 51. SEE3. exhibit tbl-ent (3). E SECTION 52. SEE4. exhibit tbl-ent (4). F SECTION 53. SEE5. exhibit tbl-ent (5). Additional reference words: 2.00 2.10 2.20 Copyright Microsoft Corporation 1993.