Skip to Content
Custom Search

INSPECT TALLYING FOR CHARACTER

 

INSPECT TALLYING FOR CHARACTER     
 
The following COBOL program depicts the use of 
INSPECT TALLYING FOR CHARACTER     
 
       IDENTIFICATION DIVISION.
       PROGRAM-ID. PGM032.
       AUTHOR. MAINFRAMEWIZARD.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 TEST-STRING   PIC X(40) VALUE SPACES.
       01 WS-COUNTER    PIC 9(9)  VALUE ZEROES.
       01 SEARCH-STRING PIC X(2)  VALUE SPACES.
       PROCEDURE DIVISION.
       10000-MAIN-PARA.
             MOVE 'THIS IS TEST STRING TO TEST LEADING SPACES'
              TO  TEST-STRING
             INSPECT TEST-STRING TALLYING WS-COUNTER FOR
             CHARACTERS
             DISPLAY 'COUNT OF ALL CHARACTERS IS = '
               WS-COUNTER
             STOP RUN.
 
 
The output of the program is 
 
COUNT OF ALL CHARACTERS IS = 000000040                                                                                   

Comments

Post new comment

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.

Click the +1 button  below to share it with your friends and colleagues

 

Share this if you liked it!

 

Disclaimer



Who's online

There are currently 0 users and 30 guests online.
Dr. Radut | page