MainframeMaster

COBOL Tutorial

COBOL REVERSE-VIDEO - Quick Reference

Progress0 of 0 lessons

Overview

REVERSE-VIDEO is a display attribute used in COBOL screen handling to display text with inverted colors, typically showing white text on a black background instead of the normal black text on white background. It is used to highlight important information.

Purpose and Usage

  • Visual emphasis - Highlight important information on screen
  • Error highlighting - Make error messages stand out
  • Status indicators - Show critical status information
  • User interface - Enhance screen readability
  • Warning display - Draw attention to warnings

Visual Effect Concept

Normal text: Hello World
REVERSE-VIDEO: Hello World
Inverted colors for emphasis

REVERSE-VIDEO creates high contrast for important information.

Syntax

REVERSE-VIDEO is used in the SCREEN SECTION to define display attributes for screen fields.

Basic Syntax

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
* Basic REVERSE-VIDEO syntax in SCREEN SECTION SCREEN SECTION. 01 ERROR-SCREEN. 05 ERROR-MESSAGE PIC X(50) REVERSE-VIDEO. * With other attributes 01 WARNING-SCREEN. 05 WARNING-TEXT PIC X(40) REVERSE-VIDEO BLINK. * In PROCEDURE DIVISION PROCEDURE DIVISION. DISPLAY ERROR-SCREEN DISPLAY WARNING-SCREEN * Complete example IDENTIFICATION DIVISION. PROGRAM-ID. REVERSE-VIDEO-EXAMPLE. ENVIRONMENT DIVISION. CONFIGURATION SECTION. DATA DIVISION. WORKING-STORAGE SECTION. 01 ERROR-TEXT PIC X(50) VALUE "CRITICAL ERROR OCCURRED". SCREEN SECTION. 01 ERROR-DISPLAY. 05 ERROR-FIELD PIC X(50) REVERSE-VIDEO FROM ERROR-TEXT. PROCEDURE DIVISION. MAIN-LOGIC. DISPLAY ERROR-DISPLAY STOP RUN.

REVERSE-VIDEO is applied to screen fields in the SCREEN SECTION.

Attribute Combinations

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
* REVERSE-VIDEO with BLINK 01 URGENT-MESSAGE. 05 URGENT-TEXT PIC X(30) REVERSE-VIDEO BLINK. * REVERSE-VIDEO with UNDERLINE 01 IMPORTANT-FIELD. 05 IMPORTANT-TEXT PIC X(20) REVERSE-VIDEO UNDERLINE. * Multiple attributes 01 CRITICAL-ALERT. 05 ALERT-TEXT PIC X(40) REVERSE-VIDEO BLINK UNDERLINE. * Conditional REVERSE-VIDEO 01 STATUS-DISPLAY. 05 STATUS-TEXT PIC X(15) REVERSE-VIDEO WHEN STATUS-CODE = "ERROR".

REVERSE-VIDEO can be combined with other display attributes.

Practical Examples

These examples demonstrate how to use REVERSE-VIDEO effectively in different screen display scenarios.

Error Message Display

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
IDENTIFICATION DIVISION. PROGRAM-ID. ERROR-DISPLAY. DATA DIVISION. WORKING-STORAGE SECTION. 01 ERROR-MESSAGE PIC X(60) VALUE "SYSTEM ERROR: INVALID INPUT DETECTED". 01 STATUS-CODE PIC X(10) VALUE "ERROR". SCREEN SECTION. 01 ERROR-SCREEN. 05 BLANK SCREEN. 05 LINE 5 COLUMN 10 VALUE "ERROR MESSAGE:". 05 LINE 6 COLUMN 10 PIC X(60) REVERSE-VIDEO FROM ERROR-MESSAGE. 05 LINE 8 COLUMN 10 VALUE "STATUS:". 05 LINE 8 COLUMN 18 PIC X(10) REVERSE-VIDEO FROM STATUS-CODE. 05 LINE 10 COLUMN 10 VALUE "PRESS ENTER TO CONTINUE". PROCEDURE DIVISION. MAIN-LOGIC. DISPLAY ERROR-SCREEN ACCEPT OMITTED STOP RUN.

REVERSE-VIDEO highlights error messages for immediate attention.

Status Indicator

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
* Status display with REVERSE-VIDEO DATA DIVISION. WORKING-STORAGE SECTION. 01 SYSTEM-STATUS PIC X(20) VALUE "SYSTEM OFFLINE". 01 USER-ACTION PIC X(30) VALUE "PLEASE WAIT". SCREEN SECTION. 01 STATUS-SCREEN. 05 BLANK SCREEN. 05 LINE 3 COLUMN 5 VALUE "SYSTEM STATUS:". 05 LINE 3 COLUMN 20 PIC X(20) REVERSE-VIDEO FROM SYSTEM-STATUS. 05 LINE 5 COLUMN 5 VALUE "ACTION REQUIRED:". 05 LINE 5 COLUMN 20 PIC X(30) REVERSE-VIDEO BLINK FROM USER-ACTION. 05 LINE 7 COLUMN 5 VALUE "PRESS ANY KEY TO CONTINUE". PROCEDURE DIVISION. SHOW-STATUS. DISPLAY STATUS-SCREEN ACCEPT OMITTED EXIT.

REVERSE-VIDEO with BLINK creates urgent status indicators.

Data Entry Validation

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
* Form with REVERSE-VIDEO validation DATA DIVISION. WORKING-STORAGE SECTION. 01 USER-NAME PIC X(30). 01 VALIDATION-ERROR PIC X(50) VALUE "INVALID USER NAME - PLEASE RE-ENTER". SCREEN SECTION. 01 INPUT-FORM. 05 BLANK SCREEN. 05 LINE 3 COLUMN 5 VALUE "ENTER USER NAME:". 05 LINE 3 COLUMN 22 PIC X(30) TO USER-NAME. 05 LINE 5 COLUMN 5 PIC X(50) REVERSE-VIDEO FROM VALIDATION-ERROR WHEN USER-NAME = SPACES. PROCEDURE DIVISION. GET-USER-INPUT. DISPLAY INPUT-FORM ACCEPT INPUT-FORM IF USER-NAME = SPACES DISPLAY INPUT-FORM ACCEPT INPUT-FORM END-IF.

REVERSE-VIDEO shows validation errors clearly.

Menu Highlighting

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
* Menu with REVERSE-VIDEO selection DATA DIVISION. WORKING-STORAGE SECTION. 01 MENU-CHOICE PIC X(1). 01 SELECTED-OPTION PIC X(20). SCREEN SECTION. 01 MENU-SCREEN. 05 BLANK SCREEN. 05 LINE 3 COLUMN 10 VALUE "MAIN MENU". 05 LINE 5 COLUMN 5 VALUE "1. PROCESS DATA". 05 LINE 6 COLUMN 5 VALUE "2. VIEW REPORTS". 05 LINE 7 COLUMN 5 VALUE "3. EXIT". 05 LINE 9 COLUMN 5 VALUE "ENTER CHOICE:". 05 LINE 9 COLUMN 18 PIC X(1) TO MENU-CHOICE. 05 LINE 11 COLUMN 5 PIC X(20) REVERSE-VIDEO FROM SELECTED-OPTION WHEN MENU-CHOICE = "1" OR "2" OR "3". PROCEDURE DIVISION. SHOW-MENU. EVALUATE MENU-CHOICE WHEN "1" MOVE "PROCESSING DATA..." TO SELECTED-OPTION WHEN "2" MOVE "VIEWING REPORTS..." TO SELECTED-OPTION WHEN "3" MOVE "EXITING PROGRAM..." TO SELECTED-OPTION END-EVALUATE DISPLAY MENU-SCREEN.

REVERSE-VIDEO highlights selected menu options.

Best Practices and Considerations

Understanding best practices ensures effective use of REVERSE-VIDEO in COBOL applications.

Best Practices

  • Use sparingly - Reserve for truly important information
  • Consistent application - Use the same way throughout your application
  • Combine with other attributes - Use BLINK for urgent messages
  • Test on different terminals - Ensure compatibility across platforms
  • Consider accessibility - Some users may have difficulty with high contrast
  • Document usage - Clearly define when REVERSE-VIDEO is used

Common Use Cases

Use CaseDescriptionExample
Error MessagesHighlight system errors"INVALID INPUT DETECTED"
WarningsShow important warnings"SYSTEM MAINTENANCE SCHEDULED"
Status IndicatorsDisplay system status"PROCESSING..."
Key InformationHighlight critical data"BALANCE: $1,000.00"
Menu SelectionsShow selected options"CURRENT SELECTION: OPTION 2"

Performance Considerations

  • Minimal impact - REVERSE-VIDEO has negligible performance effect
  • Display operation - Only affects screen rendering time
  • Terminal dependent - Performance may vary by terminal type
  • Batch processing - No effect in batch environments
  • Memory usage - No additional memory requirements

REVERSE-VIDEO Quick Reference

UsageSyntaxExample
Basic REVERSE-VIDEOPIC X(n) REVERSE-VIDEO05 ERROR-FIELD PIC X(50) REVERSE-VIDEO
With BLINKPIC X(n) REVERSE-VIDEO BLINK05 URGENT PIC X(30) REVERSE-VIDEO BLINK
With UNDERLINEPIC X(n) REVERSE-VIDEO UNDERLINE05 IMPORTANT PIC X(20) REVERSE-VIDEO UNDERLINE
ConditionalPIC X(n) REVERSE-VIDEO WHEN condition05 STATUS PIC X(15) REVERSE-VIDEO WHEN ERROR
Multiple attributesPIC X(n) REVERSE-VIDEO BLINK UNDERLINE05 CRITICAL PIC X(40) REVERSE-VIDEO BLINK UNDERLINE

Test Your Knowledge

1. What is the primary purpose of REVERSE-VIDEO in COBOL?

  • To reverse the order of characters in a string
  • To display text with inverted colors for emphasis
  • To reverse the order of records in a file
  • To reverse mathematical operations

2. In which COBOL section is REVERSE-VIDEO typically used?

  • DATA DIVISION
  • SCREEN SECTION
  • PROCEDURE DIVISION
  • ENVIRONMENT DIVISION

3. What is the visual effect of REVERSE-VIDEO?

  • Text appears in bold
  • Text appears in italics
  • Text appears with inverted colors
  • Text appears underlined

4. Can REVERSE-VIDEO be combined with other display attributes?

  • No, it can only be used alone
  • Yes, with other attributes like BLINK and UNDERLINE
  • Only with BLINK attribute
  • Only with UNDERLINE attribute

5. What is a common use case for REVERSE-VIDEO?

  • Highlighting error messages
  • Reversing string data
  • Mathematical calculations
  • File operations

Frequently Asked Questions