Microsoft KB Archive/42328

From BetaArchive Wiki

COBOL 3.0/3.0a Adds Additional Spaces with COPY and REPLACE

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

3.00 3.00a MS-DOS

The information in this article applies to:
- Microsoft COBOL for MS-DOS, versions 3.0 and 3.0a

Summary: The COPY and REPLACE statements in COBOL versions 3.0 and 3.0a replace the specified text, but add extra incorrect spaces. This is noted to be a problem only when REPLACING partial words or variables.

More Information: When using the statements COPY and REPLACE together, the string that is being searched for must be a complete word or variable; otherwise, the replacement string will contain extra spaces prior to its insertion and also extra spaces just after its insertion. Code examples below illustrate this problem. The error generated, either on the screen or in a listing file, should read as follows: Name ends in Hyphen. Processed as written. Microsoft has confirmed this to be a problem in versions 3.0 and 3.0a. This problem has been corrected in Microsoft Professional Development System version 4.0 for MS-DOS and MS OS/2.

Compile Step: COBOL t-copy,,t-copy.lst,

Code Example: COBOL Source File (T-COPY.CBL): $SET ANS85 OSVS IDENTIFICATION DIVISION. PROGRAM-ID. t-copy. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 product-code. COPY copylst REPLACING ==(example)== BY ==first-==. 05 item-name PIC X(5). PROCEDURE DIVISION. EXHIBIT item-name. STOP RUN. File to Copy from (COPYLST): 05 (example)item PIC xx.

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.