Converting Strings to Upper or Lower Case
The STRLOWCASE and STRUPCASE functions convert their arguments to lower or upper case. They have the form:
result = STRLOWCASE(string)
result = STRUPCASE(string)
where string is the string to be converted to lower or upper case.
The following statements generate a table of the contents of TREES showing each name in its actual case, lower case, and upper case:
FOR I = 0, 6 DO PRINT, TREES(I), STRLOWCASE(TREES(I)), $
STRUPCASE(TREES(I)), Format = '(A,T15,A,T30,A)'
The resulting output from running this statement is:
Beech beech BEECH
Birch birch BIRCH
Mahogany mahogany MAHOGANY
Maple maple MAPLE
Oak oak OAK
Pine pine PINE
Walnut walnut WALNUT
A common use for case folding occurs when writing procedures that require input from the user. By folding the case of the response, it is possible to handle responses written in any case. For example, the following statements can be used to ask “Yes or No” style questions:
; Create a string variable to hold the response.
ANSWER = ''
READ, 'Answer Yes or No: ', ANSWER
; Compare the response to the expected answer.
IF (STRUPCASE(ANSWER) EQ 'YES') THEN
PRINT, 'Yes' else PRINT, 'No'
Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.