Contents

Previous

Next

Last

Syntax Highlighting

The CM Editor features "syntax highlighting". Syntax highlighting is a technique whereby the editor uses different colors for different elements of the script (keywords, data values, constants, comments, etc.). This section talks about the highlighting available in the CM Editor.

Basic Syntax Highlighting

As mentioned above, highlighting involves using different colors for different types of commands. This makes it easier to spot mistakes in the script. It also acts as a sort of running "spell check" on the keywords used in the script. As you are typing a keyword, "endSequence" for example, the character will be black (the default plain text color) as you are typing. When you have the entire word in place the syntax highlighting will cause the word endSequence to turn blue, if you continue to add letters to it the word will turn black again. During the time it's blue, the keyword is spelled correctly and is recognized as a valid command. Note that syntax highlighting is not the same as syntax checking. It can't tell you whether you're script is logically correct, only that the command is one it recognizes.

Definition Highlighting

The CM Edit also features a rudimentary form of "definition highlighting". The highlighter attempts to determine whether a particular variable or expression is an analog value or a bit value and then picks the color to use for highlighting based on the data type. Since the CM uses different colors for the two types of data, you can spot an improper assignment of data very quickly. Assuming the default colors, if you were to try to enter:

you would see that the types of data didn't match since CMS.B1 (a bit value) would be orange to the left of the "=" and JS1.A2 would be brown on the right side of the equation (assuming the default colors). For the equation to be correct, the two sides should be the same color.

Highlighting Levels

There are really three levels of highlighting available. The simplest is "No Highlighting". This is the fastest since the editor does not have to process its contents. All words are the same color, those colors can be specified in the Editor Options dialog.

The second level is "Standard Highlighting". At this level all known keywords and commands are highlighted. The colors used can also be set using the Editor Options dialog. Definition Highlighting is disabled.

The third level enables Definition Highlighting. It attempts to analyze items created using a %DEFINE directive to determine their data type, then dynamically adds that word to the correct list as described earlier. Thus if you write:

it will analyze the statement, decide that "Trigger" is a bit value, and it will color it orange (again assuming the default colors) whenever it appears in the script.

Successive levels of highlighting do take a bit more time, but the current editor is quite fast and enabling all three levels generally causes no real problems. If it does become slow, you can reduce the highlighting level by turning off the Definition Highlighting, this is probably the slowest of the operations. If you prefer just plain text, you can turn off all the highlighting and set the main text color and the whole file will appear in the one color. Even if you do this for the basic file creation, turning the highlighting on while debugging can be quite helpful in spotting errors in assignment types, misspelled keywords, etc.

For more info on setting the highlighting level and the color options, see the Editor Options section later in this Users Guide.