View previous topic :: View next topic |
Author |
Message |
mainfrae Beginner
Joined: 17 Feb 2006 Posts: 17 Topics: 9
|
Posted: Sat Jan 17, 2009 7:42 am Post subject: Searching a character '-' in PL/1 |
|
|
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 |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Sat Jan 17, 2009 12:52 pm Post subject: |
|
|
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 |
|
|
prino Banned
Joined: 01 Feb 2007 Posts: 45 Topics: 5 Location: Oostende
|
Posted: Sat Jan 17, 2009 4:55 pm Post subject: |
|
|
And what if the user enters 2009? |
|
Back to top |
|
|
Nic Clouston Advanced
Joined: 01 Feb 2007 Posts: 1075 Topics: 7 Location: At Home
|
Posted: Sun Jan 18, 2009 11:59 am Post subject: |
|
|
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 |
|
|
|
|