Image description: nested program structure
This image shows a program that has both directly contained and indirectly contained nested programs. Embedded comments explain the nesting; however, the comments are not in strict source-code format.
Id Division.
Program-Id. X.
* Begin comment. X is the outermost program and directly contains X1 and X2, and indirectly contains X11 and X12. End comment.
Procedure Division.
Display "I'm in X"
Call "X1"
Call "X2"
Stop Run.
Id Division.
Program-Id. X1.
* Begin comment. X1 is directly contained in X and directly contains X11 and X12. End comment.
Procedure Division.
Display "I'm in X1"
Call "X11"
Call "X12"
Exit Program.
Id Division.
Program-Id. X11.
* Begin comment. X11 is directly contained in X1 and indirectly contained in X. End comment.
Procedure Division.
Display "I'm in X11"
Exit Program.
End Program X11.
Id Division.
Program-Id. X12.
* Begin comment. X12 is directly contained in X1 and indirectly contained in X. End comment.
Procedure Division.
Display "I'm in X12"
Exit Program.
End Program X12.
End Program X1.
Id Division.
Program-Id. X2.
* Begin comment. X2 is directly contained in X. End comment.
Procedure Division.
Display "I'm in X2"
Exit Program.
End Program X2.
End Program X.
End of image description.