Project members: Inline code

With inline code members you are able to store within the project some snippets of native code (e.g. C). During code generation these code snippets are output together with other project members strictly according to the order in which the members are defined. Inline code members are represented in Composer by following bricks:

Typical application case is to use inline code to add C #include "..." directives to the generated code. In this manner you can combine the translated Chora platform-independent code with code to communicate with the target system.

Please note, an inline code member can exist only within a unit member. Moreover inline members are considered during code generation only. They have no effect during prototyping.

Add new inline code

First switch to the Composer page for the respective unit member you want to add the new inline code member.

Then, in the Gallery window, ensure that the folder Chora is opened.

Look in the folder for the template named Inline Code.

With the mouse, select the template and drag it into the Composer.

Drop the template within the Composer.

Adding a new inline code member.

Name the inline code

First ensure, that the inline code member is selected.

Press the key F2 or select the menu item EDITRename ....

Enter the new name in the Inspector window.

The name of the inline code member has no effect on the function of your application. However, it has to be unique within the unit the inline code member is defined inside.

Edit the content of the inline code

The content of inline code members is edited in the Code Editor window. For this purpose:

First ensure, that the inline code member is selected.

Press the key ENTER ...

... or double click on the inline code member with the mouse.

Conditional compiling and inline code

By using the $if, $else, $elseif and $endif Chora conditional compilation directives, parts of the inline code, depending on the target platform, can be excluded. If the condition in an $if or $elseif directive is fulfilled, the following code part is taken over. If the condition is not fulfilled, the code is ignored. For example, the following C compiler #include directive is take over only when generating code for Microsoft Win32 target:

$if $platform == Tara.Win32.* include <windows.h> $endif

Duplicate an existing inline code

You can create any number of copies of an already existing inline code member.

First ensure, that the inline code member is selected.

Press the keys CtrlC and CtrlV in succession ...

... or hold the key Ctrl pressed while you drag and drop the selected inline code member.

Finally rename the just duplicated inline code member.

Determine the position in the generated code

All members are generated strictly according to the order in which they are defined within the unit. The code generation starts always with the back most member (the member with the lowest order number). The actual order of an member can be inspected in the members area of the Inspector window. To change the code generation order you need to explicitly restack the member. For example, to arrange an inline code member at the top of the generated code, do following:

First ensure, that the inline code member is selected.

Press the keys CtrlShiftDown or select the menu item ARRANGERestack back most.

Control the code generation

With the attribute Generator you can selectively control, whether the inline code member is taken in account when generating code. Configuring this attribute with the value false will exclude the inline code member from your project.

Delete an inline code

First ensure, that the inline code member is selected.

Press the key DEL or select the menu item EDITDelete.

Attributes of an inline code

The following table shows the complete list of attributes provided by the inline code member:

Attribute name

Short description

Brick

Determines the position and the size of a inline code member brick within the Composer window.

Description

Contains the description for the inline code member.

Generator

Controls the code generation for the affected inline code member.