MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Validate every byte in a field
Goto page Previous  1, 2
 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12370
Topics: 75
Location: San Jose

PostPosted: Fri Dec 20, 2002 6:28 am    Post subject: Reply with quote

Rajeev,

I edited your post to put the code blocks to make the post more readable. you can click on the edit button and see how the CODE tags work.

When posting a reply you can see on the first line(Message Body) all tag functions for bold,italic,underline,quote,code...

so before pasting your source code click on the required button(code in this case) and after pasting the last line of your program click once again the code which will insert the closing code tag.By embedding the text in between code tags it will be easier to read and understand

Thanks

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bkelle
Beginner


Joined: 22 Jan 2003
Posts: 9
Topics: 3

PostPosted: Wed Jan 22, 2003 4:47 pm    Post subject: Reply with quote

Another way of checking would be

INSPECT FIELD TALLYING COUNT-1 FOR ALL ' '
IF COUNT-1 = ZERO AND FIELD IS ALPHABETIC
THEN PROCESS
ELSE
SET FIELD ERROR TO TRUE
END-IF
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 699
Topics: 63
Location: USA

PostPosted: Tue Jan 28, 2003 9:39 am    Post subject: Reply with quote

Thanks bkelle,

This is much better than multiple ifs.

Dibakar
Back to top
View user's profile Send private message Send e-mail
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 699
Topics: 63
Location: USA

PostPosted: Wed Feb 05, 2003 4:34 am    Post subject: Reply with quote

Sorry this didn't work since I require to pass numbers as well. Like 'AAAA, 'A1B2' etc. Is there any command to do such check in VS COBOL II?

Dibakar.
Back to top
View user's profile Send private message Send e-mail
Grant
Beginner


Joined: 02 Dec 2002
Posts: 45
Topics: 1
Location: Sydney, NSW, Australia

PostPosted: Wed Feb 05, 2003 6:17 pm    Post subject: Reply with quote

Dibakar,
I think you'll find that Taterhead's suggestion is exactly what you are looking for. It's simple and efficient.
Code:

ENVIRONMENT DIVISION.           
CONFIGURATION SECTION.           
SPECIAL-NAMES.                   
     CLASS VALID-NAME           
           'A' THRU 'Z'         
           '0' THRU '9'.         
DATA DIVISION.
WORKING-STORAGE SECTION.         
01 Var1  Pic x(4)  value 'AB12'.
01 Var2  Pic x(4)  value 'A C3'.
                                 
PROCEDURE DIVISION.             
   If Var1 VALID-NAME           
      Display 'Var1 is valid'   
   else                         
      Display 'Var1 is invalid'
   end-if.                     
                               
   If Var2 VALID-NAME           
      Display 'Var2 is valid'   
   else                         
      Display 'Var2 is invalid'
   end-if.                     
                               
   GOBACK.


The output is:

Var1 is valid
Var2 is invalid
Back to top
View user's profile Send private message
DaveyC
Moderator


Joined: 02 Dec 2002
Posts: 151
Topics: 3
Location: Perth, Western Australia

PostPosted: Wed Feb 05, 2003 9:05 pm    Post subject: Reply with quote

I agree with Grant. Special Names will build a translation table and will even be more effecient then rolling your own assembler program to do the TRT.
_________________
Dave Crayford
Back to top
View user's profile Send private message Send e-mail
Premkumar
Moderator


Joined: 28 Nov 2002
Posts: 77
Topics: 7
Location: Chennai, India

PostPosted: Wed Feb 05, 2003 11:47 pm    Post subject: Reply with quote

Beware of the non-alphabetic characters interspersed between "A" and "Z" in EBCDIC.

Define VALID-NAME class as
Code:

SPECIAL-NAMES.                     
      CLASS VALID-NAME 'A' THRU 'I'
                       'J' THRU 'R'
                       'S' THRU 'Z'
                       '0' THRU '9'.

or as Taterhead did.
Back to top
View user's profile Send private message Send e-mail
Grant
Beginner


Joined: 02 Dec 2002
Posts: 45
Topics: 1
Location: Sydney, NSW, Australia

PostPosted: Thu Feb 06, 2003 12:01 am    Post subject: Reply with quote

good pickup Premkumar ...
Back to top
View user's profile Send private message
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 699
Topics: 63
Location: USA

PostPosted: Thu Feb 06, 2003 12:38 am    Post subject: Reply with quote

Thanks again, but as I am coding for script generated source I have access to only some specific places in working storage and procedure division. So I can't use special names.

I have tried multiple IFs or multiple PERFORMs but was wondering if there exist some clever use of INSPECT to do the same.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group