MainframeMaster

COBOL Tutorial

COBOL WITH NO ADVANCING - Quick Reference

Progress0 of 0 lessons

Overview

WITH NO ADVANCING is a COBOL clause used with output operations (typically DISPLAY statements) to prevent automatic line advancement. It allows you to control the positioning of output on the screen or in output files, providing better formatting control and the ability to create custom layouts.

Purpose and Usage

  • Output formatting control
  • Custom layout creation
  • Line positioning control
  • Prevention of unwanted line breaks
  • Precise output placement

Syntax

WITH NO ADVANCING follows specific syntax patterns with output operations:

Basic Syntax

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
* Basic WITH NO ADVANCING syntax DISPLAY "Hello" WITH NO ADVANCING. DISPLAY "World" WITH NO ADVANCING. DISPLAY ".". * Multiple items on same line DISPLAY "Name: " WITH NO ADVANCING. DISPLAY customer-name WITH NO ADVANCING. DISPLAY " Age: " WITH NO ADVANCING. DISPLAY customer-age. * Formatting with spacing DISPLAY "Item: " WITH NO ADVANCING. DISPLAY item-name WITH NO ADVANCING. DISPLAY " Price: " WITH NO ADVANCING. DISPLAY item-price WITH NO ADVANCING. DISPLAY " USD".

WITH NO ADVANCING prevents line advancement after output operations.

Comparison with Default Behavior

cobol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
* Default behavior (with line advancement) DISPLAY "Line 1". DISPLAY "Line 2". DISPLAY "Line 3". * Output: * Line 1 * Line 2 * Line 3 * WITH NO ADVANCING behavior DISPLAY "Line 1" WITH NO ADVANCING. DISPLAY "Line 2" WITH NO ADVANCING. DISPLAY "Line 3". * Output: * Line 1Line 2Line 3 * Mixed usage DISPLAY "Name: " WITH NO ADVANCING. DISPLAY customer-name. DISPLAY "Address: " WITH NO ADVANCING. DISPLAY customer-address.

Practical Examples

Here are some practical uses of WITH NO ADVANCING in COBOL:

Formatted Output 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
* Formatted output with WITH NO ADVANCING PROCEDURE DIVISION. DISPLAY-CUSTOMER-INFO. * Display customer information in formatted layout DISPLAY "Customer Information:". DISPLAY "=====================". DISPLAY "ID: " WITH NO ADVANCING. DISPLAY customer-id. DISPLAY "Name: " WITH NO ADVANCING. DISPLAY customer-name. DISPLAY "Address: " WITH NO ADVANCING. DISPLAY customer-address. DISPLAY "Phone: " WITH NO ADVANCING. DISPLAY customer-phone. DISPLAY "Balance: " WITH NO ADVANCING. DISPLAY "$" WITH NO ADVANCING. DISPLAY customer-balance. DISPLAY "Status: " WITH NO ADVANCING. IF customer-active DISPLAY "ACTIVE" ELSE DISPLAY "INACTIVE" END-IF. * Output example: * Customer Information: * ===================== * ID: 123456 * Name: John Doe * Address: 123 Main St * Phone: (555) 123-4567 * Balance: $1,234.56 * Status: ACTIVE

Formatted customer information display using WITH NO ADVANCING.

Progress Indicators

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
* Progress indicators with WITH NO ADVANCING PROCEDURE DIVISION. PROCESS-RECORDS. DISPLAY "Processing records...". * Process records with progress display PERFORM UNTIL end-of-file READ input-file AT END MOVE "Y" TO end-of-file-flag NOT AT END PERFORM process-record ADD 1 TO record-counter * Display progress every 100 records IF FUNCTION MOD(record-counter, 100) = 0 DISPLAY "Processed " WITH NO ADVANCING. DISPLAY record-counter WITH NO ADVANCING. DISPLAY " records..." END-IF END-READ END-PERFORM. * Final count DISPLAY "Total records processed: " WITH NO ADVANCING. DISPLAY record-counter. * Output example: * Processing records... * Processed 100 records... * Processed 200 records... * Processed 300 records... * Total records processed: 325

Progress indicators using WITH NO ADVANCING for better formatting.

Best Practices

  • Use WITH NO ADVANCING for better output formatting control.
  • Combine WITH NO ADVANCING with regular DISPLAY for mixed formatting.
  • Use WITH NO ADVANCING to create custom layouts and forms.
  • Consider readability when using WITH NO ADVANCING extensively.
  • Test output formatting on different devices and screen sizes.
  • Document complex formatting logic for maintenance.

Common Pitfalls

  • Forgetting to add line breaks when needed, causing output to run together.
  • Overusing WITH NO ADVANCING, making output hard to read.
  • Not considering different output devices and their formatting requirements.
  • Creating overly complex formatting that is difficult to maintain.
  • Not testing output formatting thoroughly.

Test Your Knowledge

1. What is WITH NO ADVANCING in COBOL?

  • A file operation
  • An output formatting option
  • A data declaration
  • A program structure

2. What does WITH NO ADVANCING do?

  • Prevents line advancement after output
  • Advances to the next line
  • Skips lines
  • Deletes lines

3. When is WITH NO ADVANCING typically used?

  • With file operations
  • With DISPLAY statements for formatting
  • With arithmetic operations
  • With data declarations

4. What is the default behavior without WITH NO ADVANCING?

  • No line advancement
  • Automatic line advancement
  • Random line advancement
  • Conditional line advancement

5. What is the primary benefit of using WITH NO ADVANCING?

  • Faster output
  • Better output formatting control
  • Reduced memory usage
  • Improved performance

Frequently Asked Questions