` Printed Icetips Article

Icetips Article



Par2: Proper case names
2008-08-21 -- Randy Goodhew
 
Here I've added the additional single character checks and optimized the 
code.

!----------------------------------------------

Proper           PROCEDURE(STRING s)
UpperFlag     LONG,AUTO
J                    LONG,AUTO
  CODE
  s = LOWER(s)
  UpperFlag = TRUE
  LOOP J = 1 TO SIZE(s)
    CASE s[J]
    OF   '<32>'  !Space Char
    OROF '<34>'  !Double Quote "
    OROF '<39>'  !single quote  '
    OROF '<45>'  !single dash   -
    OROF '0' TO '9'
      UpperFlag = TRUE
    ELSE
      IF UpperFlag = TRUE
        s[J] = UPPER(s[J])
        UpperFlag = FALSE
      END !if
    END !loop
  END !loop
  RETURN( s )



Printed November 23, 2024, 6:10 pm
This article has been viewed/printed 35229 times.