Summary -

In this topic, we described about the Floating Comment Indicator with detailed example.

Info! Inline comments are introduced and supported from COBOL V5.1. Versions before COBOL V5.1, do not support inline comments.

A floating comment indicator (*>) can be specified anywhere in the program-text area to indicate a comment line or an inline comment. A floating comment line can start either in Area A or Area B.

For example -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 
       01 WS-VAR        PIC X(12).    *> INLINE COMMENT                 
	   
	    *> INLINE COMMENT

Rules -

  • Both characters (* and >) that form the multiple-character floating indicator must be contiguous on the same line.
    For example -
    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 
    	    *> INLINE COMMENT
    
  • The floating comment indicator must be preceded by a separator space.
    For example -
    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 
           01 WS-VAR        PIC X(12). *> INLINE COMMENT                 
    
  • All characters following the floating comment indicator up to the end of Area B are comment text.
    For example -
    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 
    	    *> INLINE COMMENT LINE CAN BE UPTO END OF THE AREA-B.
    

Practical Example -

Scenario - Below example describes how the floating comments coded in COBOL programming.

Code -

Floating Comment Code
----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
       IDENTIFICATION DIVISION.                                         
       PROGRAM-ID. FLOATCOM.                                            
       AUTHOR. MTH.                                                     
                                                                        
       PROCEDURE DIVISION.                                              
                                                                        
       *> INLINE COMMENT IN AREA-A                                      
                  *> INLINE COMMENT IN AREA-B                           
           DISPLAY "FLOATING/INLINE COMMENT DISPLAY".                   
           STOP RUN.                                                    
**************************** Bottom of Data ****************************