KCML was originally agnostic about the case of variable or function names. They were always rendered in the editor in lower case but could be typed in any case. Starting with version 5, KCML now attempts to preserve the case of its symbols without losing the ability to enter variables in any case.
KCML takes the correct case of a symbol from its definition in a DIM, LOCAL DIM, COM, DEFSUB, DEFFN, DEFFORM, DEFOBJ, DEFEVENT or $DECLARE. These are called Declaration Statements. Certain symbols, for instance the names of CALL functions, are always upper case. Other symbols such as the names of form events, method and properties have a fixed spelling built into KCML. If you refer to a new symbol without having previously declared it then it will be initially put into the programs symbol table in lower case. The editor will also underline the name to warn you that it has not been declared. If a proper declaration is added later then the underline will go away and the symbol take the case as specified in the declaration.
In an environment that uses shared partitions using SELECT @PART or libraries using LIBRARY ADD, it is possible that the declaration of a symbol is actually in the other partition or library. This can also happen with overlaid code. To allow for this, when parsing an edited statement in the editor, KCML will lookup the name of a function, object, @ variable, field or symbolic constant using the programs and libraries currently in memory. If a declaration is found it will then enter the symbol in the programs symbol table using that case otherwise it will use the default rule of all lower case.
There is a danger that if the master declaration for a symbol is in a library, that a programmer may load a program into the editor without having that environment loaded and add a line to the code including such a symbol. In this case KCML will not be able to find the correct spelling and the symbol will be entered into the programs symbol case using the default rule of all lower case. When saving a program as text using either SAVE or SAVE ASCII symbols are always lower cased except in the declaration statements where case is preserved. This is to minimize case clashes in source control systems generating spurious deltas due to instances of the above problem.
If a symbol has been created in a program with the wrong case then this can be corrected by editing a line containing the symbol in the right environment. One way to do this would be to launch the application, break in with CTRL-BREAK, CLEAR P and load the program. When editing a program line you must actually alter it to force the workbench to re-parse it. Usually all you need to do is add a redundant space.