Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Identify vowels, consonants and digits using EVALUATE

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Mon Mar 26, 2007 10:37 am    Post subject: Identify vowels, consonants and digits using EVALUATE
Reply with quote

IDENTIFICATION DIVISION.
PROGRAM-ID. EX37.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 CHAR.

88 VOWEL VALUE 'A', 'E', 'I', 'O', 'U'.
88 CONSONANT 'B' THRU 'D', 'F' THRU 'H', 'J' THRU 'N',
'P' THRU 'T', 'V' THRU 'Z'.
88 DIGIT VALUE '0' THRU '9'.
88 VALID-CHAR VALUE 'A' THRU 'B', '0' THRU '9'.
PROCEDURE DIVISION.
PARA-1.
DISPLAY 'ENTER ANY CHARACTER'.
ACCEPT CHAR.
EVALUATE VALID-CHAR
WHEN VOWEL DISPLAY ' IT IS A VOWEL'
WHEN CONSONANT DISPLAY ' IT IS A CONSONANT'
WHEN DIGIT DISPLAY ' IT IS A DIGIT'
WHEN OTHER DISPLAY ' SPECIAL CHARACTER'
END-EVALUATE.
STOP RUN.

I had used this program to identify vowels,consonants and digits when input is given. But when I entered any space or * or ? it is displaying IT IS A VOWEL as if it is a default. please clarify me on this.
Back to top
View user's profile Send private message

Narismha

New User


Joined: 22 Nov 2006
Posts: 23
Location: Mumbai

PostPosted: Mon Mar 26, 2007 1:14 pm    Post subject:
Reply with quote

Hi Venu,

Try with this.

WORKING-STORAGE SECTION.

01 WS-CHAR PIC X(01).
01 WS-VALID-CHAR PIC X(01) VALUE ' '.
88 WS-VOWEL VALUE 'A','E','I','O','U'.
88 WS-CONSONANT VALUE 'B' THRU 'D','F' THRU 'H',
'J' THRU 'N','P' THRU 'T','V' THRU 'Z'.
88 WS-DIGIT VALUE '0' THRU '9'.
88 WS-VC VALUE 'A' THRU 'Z','0' THRU '9'.

****************************************************************
P R O C E D U R E D I V I S I O N *
****************************************************************
PROCEDURE DIVISION.

ACCEPT WS-CHAR.
DISPLAY 'ENTERED CHARACTER:' WS-CHAR.
MOVE WS-CHAR TO WS-VALID-CHAR.
EVALUATE TRUE
WHEN WS-VOWEL DISPLAY ' ITS VOWEL'
WHEN WS-CONSONANT DISPLAY ' CONSONANT '
WHEN WS-DIGIT DISPLAY ' DIGIT '
WHEN WS-VC DISPLAY ' VALID CHAR'
WHEN OTHER DISPLAY ' SPECIAL CHARACTER'
END-EVALUATE.

STOP RUN.

Thanks
-Narisimha
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 686
Location: Earth

PostPosted: Mon Mar 26, 2007 1:53 pm    Post subject:
Reply with quote

Good one Narismha..
Original program was a complete mess. icon_wink.gif
Back to top
View user's profile Send private message
venosol
Warnings : 1

New User


Joined: 16 Nov 2006
Posts: 43
Location: Bangalore

PostPosted: Tue Mar 27, 2007 11:15 am    Post subject:
Reply with quote

Narismha wrote:
Hi Venu,

Try with this.

WORKING-STORAGE SECTION.

01 WS-CHAR PIC X(01).
01 WS-VALID-CHAR PIC X(01) VALUE ' '.
88 WS-VOWEL VALUE 'A','E','I','O','U'.
88 WS-CONSONANT VALUE 'B' THRU 'D','F' THRU 'H',
'J' THRU 'N','P' THRU 'T','V' THRU 'Z'.
88 WS-DIGIT VALUE '0' THRU '9'.
88 WS-VC VALUE 'A' THRU 'Z','0' THRU '9'.

****************************************************************
P R O C E D U R E D I V I S I O N *
****************************************************************
PROCEDURE DIVISION.

ACCEPT WS-CHAR.
DISPLAY 'ENTERED CHARACTER:' WS-CHAR.
MOVE WS-CHAR TO WS-VALID-CHAR.
EVALUATE TRUE
WHEN WS-VOWEL DISPLAY ' ITS VOWEL'
WHEN WS-CONSONANT DISPLAY ' CONSONANT '
WHEN WS-DIGIT DISPLAY ' DIGIT '
WHEN WS-VC DISPLAY ' VALID CHAR'
WHEN OTHER DISPLAY ' SPECIAL CHARACTER'
END-EVALUATE.

STOP RUN.

Thanks
-Narisimha


I got new ideas. One is using perform only and another is IF Else.

WORKING-STORAGE SECTION.
01 N PIC 9.
01 CHAR.
88 VOWEL VALUE 'A', 'E', 'I', 'O', 'U'.
88 CONSONANT 'B' THRU 'D', 'F' THRU 'H', 'J' THRU 'N',
'P' THRU 'T', 'V' THRU 'Z'.
88 DIGIT VALUE '0' THRU '9'.
88 VALID-CHAR VALUE 'A' THRU 'B', '0' THRU '9'.
PROCEDURE DIVISION.
PARA-1.
DISPLAY 'ENTER ANY CHARACTER'.
ACCEPT CHAR.
PERFORM UNTIL NOT VALID-CHAR AND N>1
EVALUATE TRUE
WHEN VOWEL DISPLAY ' IT IS A VOWEL'
WHEN CONSONANT DISPLAY ' IT IS A CONSONANT'
WHEN DIGIT DISPLAY ' IT IS A DIGIT'
WHEN OTHER DISPLAY ' SPECIAL CHARACTER'
END-EVALUATE
COMPUTE N=N+1
END-PERFORM.
STOP RUN.


other one is.
WORKING-STORAGE SECTION.
01 CHAR.
88 VOWEL VALUE 'A', 'E', 'I', 'O', 'U'.
88 CONSONANT 'B' THRU 'D', 'F' THRU 'H', 'J' THRU 'N',
'P' THRU 'T', 'V' THRU 'Z'.
88 DIGIT VALUE '0' THRU '9'.
88 VALID-CHAR VALUE 'A' THRU 'B', '0' THRU '9'.
PROCEDURE DIVISION.
PARA-1.
DISPLAY 'ENTER ANY CHARACTER'.
ACCEPT CHAR.
IF NOT VALID-CHAR
DISPLAY ' SPECIAL CHARACTER'
ELSE
EVALUATE VALID-CHAR
WHEN VOWEL DISPLAY ' IT IS A VOWEL'
WHEN CONSONANT DISPLAY ' IT IS A CONSONANT'
WHEN DIGIT DISPLAY ' IT IS A DIGIT'
WHEN OTHER DISPLAY 'UNKNOWN'
END-EVALUATE
END-IF
STOP RUN.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Could we identify the called modules ... elixir1986 COBOL Programming 5 Fri Jul 14, 2017 1:53 am
No new posts Identify top 30 big tables or indexes... ashek15 DB2 0 Fri Jun 16, 2017 10:01 am
No new posts Syntax to check the first 4 digits of... kshirabdhi DFSORT/ICETOOL 10 Tue May 03, 2016 12:21 pm
No new posts Identify error records krsenthil85 DFSORT/ICETOOL 11 Thu Apr 28, 2016 9:45 pm
No new posts Identify comp/comp-3 data from file bipinpeter CLIST & REXX 8 Thu Jan 14, 2016 2:27 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us