Specifications
50
This brings up a new editor window with an empty file, and we can go ahead typing anything we want. The
first thing you have probably noticed about the AnyScript editor is that it recognizes the predefined class
names and highlights them automatically. It does this all the time as you are typing, and it is a great help to
avoid misspellings that might later lead to annoying syntax errors.
Syntax Highlighting
When you start typing something, the writing color is black. This is the standard color in the editor for things
that have not been recognized. For instance, if you start defining a segment, you may type (try it!):
AnySe
And the text remains black until you type the last character of the reserved word:
AnySeg
at which point the text becomes blue. This can be a great help if you are not quite sure about the name of a
particular object. You can try typing the different forms of the name, and when you hit the right one, the
text turns blue. The editor similarly recognizes comments. If you precede the AnySeg class name with a
double-slash, the entire line turns green:
// AnySeg
Please notice that similar to C, C++, Java, and JavaScript you can turn entire blocks of code into a comment
by encapsulating it into a pair of /* */ delimiters. Another easy way to temporarily remove and re-activate
several lines from the file is to block the text in question and use the two buttons
in the toolbar of
the Editor window. This automatically places or removes double slashes in front of each line in the block.
Please also notice the so-called Documentation Comments. This is comments using the following
syntactical forms: /// ..., /** ... */, ///< ..., and /**< ... */. The Documentation Comments are related to a
given object in the model and these comments are treated specially so the information can be accesses
more convenniently after loading the model and thereby help the user of a model to understand the model
without reading the code. In the editor, the Documentation Comments do however have the same color as
other the normal comments. The Documentation Comments' form is similar to other source code systems
like JavaDoc, Doxygen, and others.
Automatic Indentation
When developing software that is hierarchical it is customary to indent the code according to the hierarchical
level of each line. This greatly improves the legibility. In the AnyScript editor we have decided that the
standard indentation for each level is two spaces. The editor automatically keeps track of where you are in
the code as defined by the start and end braces, and it helps you make the right indentations as you type.
Let us continue the segment definition we started above. Remove any leading double slashes and proceed to
type
AnySeg Segment1 = {
and hit the Return key to change line. Notice that the editor automatically indents the next line by two










