Page 1 of 1

Search for Upper case and Lower case letter

PostPosted: Wed Sep 30, 2009 8:50 pm
by raj2k3e
I need to count the appearance of Upper case and Lower case letter.
I used SET CONTROL 'L' to avoid converting characters to upper case.
how can I examine for upper case letters/ lower case letters
I will really appreciate your help Thanks

Re: Search for Upper case and Lower case letter

PostPosted: Mon Nov 23, 2009 1:40 pm
by RGZbrog
The MASK conditional can be used to test for upper or lower case characters in an alphanumeric variable. REDEFINE the variable so that you can test character by character.
DEFINE DATA LOCAL
1 #M (I4)          CONST <25>
1 #ALPHA (A25)     INIT <'A1b2 C3d4 E5f6 G7h8 I9J0'>
                   1 REDEFINE #ALPHA
  2 #A (A1/#M)
1 #U (I4)
1 #L (I4)
1 #I (I4)
END-DEFINE
FOR #I = 1 #M
  DECIDE FOR FIRST CONDITION
    WHEN #A (#I) = MASK (U)
         ADD 1 TO #U
    WHEN #A (#I) = MASK (L)
         ADD 1 TO #L
    WHEN NONE
         IGNORE
  END-DECIDE
END-FOR
DISPLAY (SG=F)
        'String' #ALPHA
        'Upper'  #U
        'Lower'  #L
END