View previous topic :: View next topic
|
Author |
Message |
jackal Currently Banned New User
Joined: 21 Jan 2006 Posts: 48 Location: india
|
|
|
|
Hi,i want 2 accept a string if its first 2 bytes contains capital letters help me pls.E.G HB222 |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Jackal,
You don't show us how the string is defined in the COBOL pgm. If it's:
05 fld-a pic x(005).
You can use:
Code: |
if fld-a(1:2) = 'HB'
perform 200-accept-string
end-if |
|
|
Back to top |
|
|
jackal Currently Banned New User
Joined: 21 Jan 2006 Posts: 48 Location: india
|
|
|
|
Hi mmwife,i got your answer but the problm is to accept only tht string whch is having 1st 2 char capital not only HB.
E.G 01 A pic X(5).
Accept strngs like AC222
DM562
thanx in advance |
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 419 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
here's some psuedo code
[code]
if field(1:1) => 'A' and field(1:1) <='Z' and field(2:1) =>'A' and field(2:1) <= 'Z'
then accept
else ...
endif
[/code |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Jackl,
Sorry, I misunderstood.
You can try something like this:
CONFIGURATION SECTION.
SPECIAL NAMES. CLASS UP-ALPHA IS A THRU I J THRU R S THRU Z.
In PD.
if fld-a(1:2) is up-alpha
perform 200-accept-string
end-if
What Dave suggests can be dangerous since A - Z are not contiguous in the coallting sequence. But since you 're dealing w/printable chars you may get away with it.
Some of the printable chars other than A thru Z that exist in that range are "}" "\". There are 2 or 3 others but there not usually seen in print.
So if that doesn't seem a threat to you, Dave's solution is fine.
The solution I offered is similar to the IF NUMERIC/IF ALPHABETIC clauses you've seen on occasion. This one (UP-ALPHA) is custom made. |
|
Back to top |
|
|
jackal Currently Banned New User
Joined: 21 Jan 2006 Posts: 48 Location: india
|
|
|
|
Thanx alot mmwife and dneuforth 4 ur assistance.
Jackal |
|
Back to top |
|
|
dneufarth
Active User
Joined: 27 Apr 2005 Posts: 419 Location: Inside the SPEW (Southwest Ohio, USA)
|
|
|
|
mmwife,
good point on the extra characters in the A to Z range
I forgot about that. |
|
Back to top |
|
|
M.Bhavani Prasad
New User
Joined: 10 Mar 2006 Posts: 6 Location: Hyderabad
|
|
Back to top |
|
|
|