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 (*>) is a comment that starts with *> anywhere in the program-text area (Area-A and Area-B).
  • The comments starting with *> are called as inline comments or floating comment lines.
  • 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 floating indicator must be contiguous on the same line.

    For example -
    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 
    	    *> INLINE COMMENT
    
  • A separator space must precede the floating comment indicator.

    For example -
    ----+----1----+----2----+----3----+----4----+----5----+----6----+----7-- 
           01 WS-VAR        PIC X(12). *> INLINE COMMENT                 
    
  • All characters following the floating comment indicator are considered as a comment.

    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 ****************************