Search for Upper case and Lower case letter



Software AG's platform-independent programming language with full support for open-source and Internet applications

Search for Upper case and Lower case letter

Postby raj2k3e » Wed Sep 30, 2009 8:50 pm

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
raj2k3e
 
Posts: 1
Joined: Wed Sep 30, 2009 8:48 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Search for Upper case and Lower case letter

Postby RGZbrog » Mon Nov 23, 2009 1:40 pm

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
User avatar
RGZbrog
 
Posts: 101
Joined: Mon Nov 23, 2009 1:34 pm
Location: California, USA
Has thanked: 0 time
Been thanked: 0 time


Return to Natural