Code Editor/en

Aus expecco Wiki (Version 2.x)
Version vom 1. April 2014, 15:04 Uhr von Cg (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „thumb|300px|Code Editor The code editor is used to view and edit the source code of an elementary block. It is fo…“)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen
Code Editor

The code editor is used to view and edit the source code of an elementary block. It is found on the "Code" tab after selecting an elementary block in the navigation tree.

To the right, you see an example for some code in the editor.


The editor consists of a language drop down list item at the top, and a code editor area, which covers the rest of the editor's space. The code input area is a regular text editor which provides syntax coloring and some code-related functions on its popup (right button) menu.

The drop down list selects the programming language in which the block is to be coded. If changed, the system tries to convert the current code into the newly selected language. The block's icon is adjusted depending on the language.

When an elementary block is initially created, some template code is shown in the editor. This consists of the "execute" function body, a comment which gives advice on how to access the input and output values, and a transcript command which prints a standard output message to the transcript.

Usually, you will cut out the comment and the transcript command, and replace it by your own code. The function name and body delimiters should be left as is. While typing, a just-in-time parser performs syntax coloring and some syntactic and semantic checks. Most errors and typos are thus detected immediately at editing time.

The expecco API describes some appropriate method calls for JavaScript and Smalltalk. To access the full protocol of the underlying framework classes, use a system browser from the tools menu.

Programming Languages[Bearbeiten]

Currently, two programming languages are built right into expecco. These are translated into an internal compact bytecode form, whenever code is "accepted", and further compiled to machine code whenever the action block is first invoked. The languages are the system's underlying Smalltalk language and a JavaScript lookalike language, which follows the syntax of JavaScript, but has an object and inheritance behavior of the underlying Smalltalk system (i.e. it is class- not instance based, and does not support dynamic change of an object's slot layout).

These builtin languages are fully supported by the debugger: you can place breakpoints (called "halts") into the code, single step, inspect local variables etc.

Other (non-builtin) languages are processed and executed by external interpreters. For example, shell and batch scripts are executed by forwaring the code to an appropriate command line interpretes. Groovy code is forwarded to a Groovy interpreter running inside a Java VM. Ruby, Python or Tcl programs can be executed via an external scripting engine. Debugging facilities are limited for those external languages (no single stepping, for example).

Editor Functions and Keyboard Shortcuts[Bearbeiten]

The editor provides the most common edit functions both via its right-button popup menu and via keyboard shortcuts. The most useful operations are:

  • Cut - CTRL-x
  • Copy - CTRL-c
  • Paste - CTRL-v
  • Undo - CTRL-z
  • Again - F8 (repeats the last replace or cut operation)
  • DoIt - CTRL-d (the selected text is executed)
  • PrintIt - CTRL-p (the selected text is executed and inserted after the selection)

DoIt and PrintIt[Bearbeiten]

Especially the "DoIt" and "PrintIt" functions deserve more explanation as they are often very useful. These interpret the selected text as a code fragment of the programming language and execute it. For example, if you select "Math.sin(45.degreesToRadians)" in a JavaScript editor, that code is interpreted and the result pasted at the cursor postition.
Useful JavaScript expressions are:

    Date.today()
    Time.now()
    UUID.new()
    OperatingSystem.getHostName()

or in Smalltalk:

    Date today 
    Time now 
    UUID new 
    OperatingSystem getHostName

For a full list of useful expressions, please refer to the [Smalltalk/X Online Documentation].

Again (repeat last edit)[Bearbeiten]

The "Again" operation - press F8 or select it from the operations (= right-button) menu - repeats the last delete or replace operation, after searching for the next occurrence of the original string. So, to incrementally rename all occurrences of "foo" with "bar", find the very first occurrence "foo", select it, type "bar" over it. This is the first edit operation. Then press F8 to repeat this for the next occurrence of "foo" in the text.

The operations menu also offers an "Again until End" function in its "more" submenu. This performs multiple "Again" operations, until the original string is no longer found.


For other editors see: Editors

The full online documentation can be found under: Online Documentation



Copyright © 2014-2024 eXept Software AG