View previous topic :: View next topic
|
Author |
Message |
paritosh mathur
New User
Joined: 10 Apr 2006 Posts: 14
|
|
|
|
Code: |
01 VALID-SW PIC X(02).
88 VALID VALUE '1' THRU '30'.
MOVE '1*' TO VALID-SW.
DISPLAY 'VALID-SW - ' VALID-SW.
IF VALID
DISPLAY 'RITE'
ELSE
DISPLAY 'NOT RITE'
END-IF.
MOVE '2*' TO VALID-SW.
DISPLAY 'VALID-SW - ' VALID-SW.
IF VALID
DISPLAY 'RITE'
ELSE
DISPLAY 'NOT RITE'
END-IF.
MOVE '3*' TO VALID-SW.
DISPLAY 'VALID-SW - ' VALID-SW.
IF VALID
DISPLAY 'RITE'
ELSE
DISPLAY 'NOT RITE'
END-IF.
MOVE '*1' TO VALID-SW.
DISPLAY 'VALID-SW - ' VALID-SW.
IF VALID
DISPLAY 'RITE'
ELSE
DISPLAY 'NOT RITE'
END-IF.
MOVE '1' TO VALID-SW.
DISPLAY 'VALID-SW - ' VALID-SW.
IF VALID
DISPLAY 'RITE'
ELSE
DISPLAY 'NOT RITE'
END-IF. |
i have validation on one indicator in my module. its range is 1 to 30. any value other than this is not right. However when i give 1*, 2*, 3* it accepts that value as valid. [* is any special character].
Same if i extend the range to 40, it accepts 4*.
here is the output.
Code: |
VALID-SW - 1*
RITE
VALID-SW - 2*
RITE
VALID-SW - 3*
RITE
VALID-SW - *1
NOT RITE
VALID-SW - 1
RITE |
Quote: |
why does it happen |
|
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Code: |
01 VALID-SW PIC X(02).
88 VALID VALUE '1' THRU '30'. |
This is an alphanumeric field. Since you did not say '01' THRU '30' the system assumes you mean '1 ' (that's a blank after a 1) is the starting value. '1*' is perfectly valid in this case, as it's in the range you specified -- and so is '1Z'. Maybe if you say what you're trying to do? |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Code: |
01 VALID-SW PIC X(02).
01 VALID-SW-R PIC 9(02).
88 VALID VALUE 1 THRU 30. |
This should work. ( I havent tested it though.)
What you defined is
VALUE '1b' THRU '30'. where b is space.
So the whole range of values between x'F140' TO X'F340' will set the switch VALID. 1* = x'F15C' so the switch is set. |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Forgot to add redefines in my last post-
Code: |
01 VALID-SW PIC X(02).
01 VALID-SW-R redefines VALID-SW PIC 9(02).
88 VALID VALUE 1 THRU 30. |
If this is not what you wanted, as Robert already asked, please let us know what exactly are you trying to achieve. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
agkshirsagar wrote: |
Code: |
01 VALID-SW PIC X(02).
01 VALID-SW-R PIC 9(02).
88 VALID VALUE 1 THRU 30. |
This should work. ( I havent tested it though.)
What you defined is
VALUE '1b' THRU '30'. where b is space.
So the whole range of values between x'F140' TO X'F340' will set the switch VALID. 1* = x'F15C' so the switch is set. |
This will allow values of 01 thru 30 and may cause an error for nonnumeric values. |
|
Back to top |
|
|
paritosh mathur
New User
Joined: 10 Apr 2006 Posts: 14
|
|
|
|
agkshirsagar wrote: |
Code: |
01 VALID-SW PIC X(02).
01 VALID-SW-R PIC 9(02).
88 VALID VALUE 1 THRU 30. |
This should work. ( I havent tested it though.)
What you defined is
VALUE '1b' THRU '30'. where b is space.
So the whole range of values between x'F140' TO X'F340' will set the switch VALID. 1* = x'F15C' so the switch is set. |
i accept the case of '1b'. but then what is the problem with 2* 3* .??? |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
Explanation remains the same-
2* = x'f25c' 3*= 'f35c' both fall in the range x'F140' TO X'F3F0'.
Did I mention F340 in last post? It was a typo. Sorry if that confused you. I am not good with the HEX values you see. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
For the posted code, you either need a MOVE from VALID-SW to VALID-SW-R or a REDEFINES in VALID-SW-R on VALID-SW. The original code defines as valid all hex values from 'F140' to 'F3F0'; 'F15C' IS '1*' and 'F25C' is '2*' and both are definitely in the range specified.[/quote] |
|
Back to top |
|
|
paritosh mathur
New User
Joined: 10 Apr 2006 Posts: 14
|
|
|
|
thanx guys. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
You might try this. . .
Code: |
01 VALID-SW PIC XX.
88 VALID VALUES ARE '01' THRU '09'
'10' THRU '19'
'20' THRU '29'
'30'.
|
|
|
Back to top |
|
|
|