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 

Searching a character '-' in PL/1

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
mainfrae
Beginner


Joined: 17 Feb 2006
Posts: 17
Topics: 9

PostPosted: Sat Jan 17, 2009 7:42 am    Post subject: Searching a character '-' in PL/1 Reply with quote

Hi All,

I am new to PL/1 and i am having a requirement like below,

I have an variable(year) of 4 bytes in the online screen.

In the online screen, if the user enters the year as "-" in the first byte(OUT OF 4 BYTES), i will retrieve the current year and display on the screen and it is working fine.

But if the user enters "-" in 2nd to 4th byte(or any one of the position other than 1st byte) in the online screen, i want to through an error

Even if the 1st 2 bytes of the variable is entered with '--', i want to throw an error.

To summarise it , other than the 1st byte position if the user enters "-" in the variable on the online screen , i want to throw an error. At the same time, if the user enters "--" in 1st byte as well as some other byte also i want to throw an error.

Please let me know how to do it in PL/1 with the syntax( I mean to validate it)
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Sat Jan 17, 2009 12:52 pm    Post subject: Reply with quote

One way is to overlay an array of four elements of 1 byte on the year field and check the array

[code:1:e98f73c393]DCL YEAR CHAR(4);
DCL OLY_YEAR(4) CHAR(1) DEF YEAR POS(1);
DCL DASH_CTR FIXED BIN(7) INIT(0);
:
:
IF YEAR
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
prino
Banned


Joined: 01 Feb 2007
Posts: 45
Topics: 5
Location: Oostende

PostPosted: Sat Jan 17, 2009 4:55 pm    Post subject: Reply with quote

And what if the user enters 2009?
Back to top
View user's profile Send private message
Nic Clouston
Advanced


Joined: 01 Feb 2007
Posts: 1075
Topics: 7
Location: At Home

PostPosted: Sun Jan 18, 2009 11:59 am    Post subject: Reply with quote

Further to my post above:

as the only valid combo is dash blank blank blank all you need is:

[code:1:5b6d786785]IF YEAR
_________________
Utility and Program control cards are NOT, repeat NOT, JCL.
Back to top
View user's profile Send private message
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
Page 1 of 1

 
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