Working With Model Items and Diagrams > Working with model items > Code editor > Overview of the code editor
  
Overview of the code editor
The Code Editor is a syntax aware editor that helps you write code for supported properties.
The Code Editor includes the following features:
Language support for different code languages.
Line numbers.
Customizable syntax colors.
Autocomplete for code elements.
Node collapsing and expanding.
These features can be used within the Property Pages, or you can click the Editor button to open the Code Editor window and Code Editor toolbar.
When the text in the Code Editor window has been changed, an asterisk appears in the Code Editor tab. You can click the Save button to save any changes that have been made to the code.
Supported code languages
The language that is used by the Code Editor determines which syntax colors are used, which keywords are used in autocomplete, and how collapsible nodes are identified.
You can use the following Language types for the Code Editor:
C++
HTML - supports HTML and ASP
JScript
LUA
Pascal
Python
SQL
VB
For the code languages ACS generates, use the following Code Editor language types:
For Ada set the Language property to Pascal
For C set the Language property to C++
For C# set the Language property to C++
For C++ set the Language property to C++
For SQL set the Language property to SQL
For Visual Basic set the Language property to VB
No language is required for Arinc 653 for PikeOS, Arinc 653 for VxWorks, and IDL because Operation Body code is not generated.
If required, you can create schema files to support other code languages.
Language used by the Code Editor
You can specify the language to use when using the Code Editor to edit the following properties:
The Body property of an Operation, Opaque Action or Value Specification Action.
The Action, Change Expression, Guard Condition and Time Expression properties of an Event Action Block.
For script based properties, the Code Editor always uses Visual Basic as the language.
You can specify a Code Editor language to use for the following items:
Model
Package
Event Action Block
Opaque Action
Operation
Value Specification Action
When editing a property using the Code Editor, the Code Editor searches the following items in turn until it finds a set Language property to use:
The Language property that is set for the item that owns the property (if there is one).
If a Stereotype is applied to the item, the Language property that is set for the Profile package that owns that Stereotype.
The Language property that is set for each parent Package in turn.
The Language property that is set for the Model.
If no set Language property is found, the Code Editor uses C++, unless the Code Editor is editing a script property. When editing script properties, the Code Editor language is always Visual Basic, irrespective of the Language that is set for parent Packages and the Model.
* 
The specified Code Editor language is displayed in the right-most pane of the status bar.
If no language is specified, then the default language C++ is displayed.
Code Editor options
The options for the Code Editor appear on the Tool Options dialog.
To set Code Editor options: on the Tools menu, click Options. Click the Code Editor entry, and then set the options as required on the Editor, Editor Font and Syntax Color tabs.
* 
The Syntax Color tab appears in the Tool Options dialog only when the Code Editor is open in a separate window.
For information about the available options, see Tool options dialog - code editor.
Opening the Code Editor window
When the Property Pages are showing a property that can be edited by the Code Editor, you can click the Edit button to open the code in the Code Editor window.
When making changes to code in the Code Editor windows, those changes are not saved to the Model until you click the Save toolbar button, press CTRL+S, or close the Code Editor window and click Save.
Where there are unsaved changes in the Code Editor window, an asterisk appears on the Code Editor window tab.
Autocomplete
As you type text in the Code Editor you can pause to let the Autocomplete list appear. You can insert the required keyword by clicking it. Alternatively, you can use the arrow keys and Enter key to select and insert the required keyword.
The keywords that are available in the Autocomplete list are dependent on the Language type.
You can set the delay before the Autocomplete list appears on the Tool Options dialog. If you set the Delay for Autocomplete to 0, the Autocomplete list appears only when you press Ctrl + Space.
Code Editor toolbar
The Code Editor toolbar appears when the Code Editor window is open.
Use the ToolTips on the buttons to see what each button does.
Collapsible nodes
The Code Editor supports collapsible nodes in the code. How collapsible nodes are identified can vary with different languages. For example, for C++, collapsible nodes are identified through braces, that is, { and } characters.
You can hover the mouse pointer over a collapsed node to view its content in a ToolTip.
Model object references
You can insert model object references into your code through the Code Editor.
A model object reference is a textual reference to a dictionary item or diagram. You can right-click a model object reference, and then perform standard operations on the referenced object, such as viewing its properties. If a reference item is renamed, the new name appears in your code. If a referenced item is deleted from the model, model object references to that item become normal text formatted with strikethrough.
To add a model object reference to your code, drag the item you want to reference to the required position in the Code Editor.
Finding text
To open the Find dialog: Press CTRL+F.
To open the Find and Replace dialog: Press CTRL+H.
To find text through the Code Editor toolbar: in the search box, type or select the text you want to find and then press Enter to the next occurrence of the text, or press SHIFT+ENTER to find the previous occurrence of the text.
After searching for text, you can use F3 to find the next occurrence of that text, or SHIFT+F3 to find the previous occurrence of that text.
To search for the next occurrence of text that is selected: press CTRL+F3.
Keyboard shortcuts
The Code Editor includes keyboard shortcuts to help you quickly write your code.
For more information about the keyboard shortcuts you can use, see Keyboard shortcuts - Code Editor.
Supported properties
You can use the Code Editor to edit the following item properties:
Dependency
Derivation Script (language is always Visual Basic)
Event Action Block properties:
Action
Change Expression
Guard Condition
Time Expression
Opaque Action properties:
Body
Operation properties:
Body
Script item properties
Script (language is always Visual Basic)
Stereotype properties:
Diagram Toolbar Command Script (language is always Visual Basic)
Double Click Script (language is always Visual Basic)
Menu Command Script (language is always Visual Basic)
On Delete Script (language is always Visual Basic)
On Drop Script (language is always Visual Basic)
On Model Close Script (language is always Visual Basic)
On Model Open Script (language is always Visual Basic)
Tag Definition properties:
Derivation Script (language is always Visual Basic)
Value Specification Action properties:
Body
Variant properties:
Derivation Script (language is always Visual Basic)
Validation Script (language is always Visual Basic)
Variation Point properties:
Validation Script (language is always Visual Basic)