! ----- CAPITALIZE_FIRST.FUN ----- ! ! ----- FUNCTION TO ENSURE THE FIRST (AND ONLY THE FIRST) ----- ! ----- LETTER OF A STRING IS CAPITALIZED ----- ! ! ----- Last Change 07/02/93 by Brian Lomasky ----- ! FUNCTION STRING CAPITALIZE_FIRST(STRING NAME_TO_CAPITALIZE) %INCLUDE "NUSER.INC" DECLARE WORD TEMP ! TEMPORARY WORD VARIABLE ! ----- MAPPED VARIABLE FOR CAPITALIZE_FIRST FUNCTION ----- MAP (CAPITAL) STRING MAPPED_STRING = 32% MAP (CAPITAL) BYTE MAPPED_BYTES(31%) ! ----- EXIT IF NO STRING WAS PASSED ----- IF NAME_TO_CAPITALIZE = "" THEN CAPITALIZE_FIRST = "" EXIT FUNCTION END IF ! ----- MOVE TO MAPPED DATA FOR SUBSEQUENT MODIFICATION ----- MAPPED_STRING = NAME_TO_CAPITALIZE FOR TEMP = 1% TO LEN(NAME_TO_CAPITALIZE) SELECT MAPPED_BYTES(TEMP - 1%) CASE 65% TO 90% ! "A" TO "Z" ! ----- LOWERCASE ONLY LETTERS AFTER THE ----- ! ----- FIRST LETTER ----- IF TEMP > 1% THEN MAPPED_BYTES(TEMP - 1%) = & MAPPED_BYTES(TEMP - 1%) & OR 32% END IF CASE 97% TO 122% ! "a" TO "z" ! ----- UPPERCASE ONLY THE FIRST LETTER ----- IF TEMP = 1% THEN MAPPED_BYTES(TEMP - 1%) = & MAPPED_BYTES(TEMP - 1%) & AND NOT 32% END IF END SELECT NEXT TEMP ! ----- RETURN MODIFIED STRING ----- CAPITALIZE_FIRST = LEFT(MAPPED_STRING, LEN(NAME_TO_CAPITALIZE)) END FUNCTION