Tools Notepad/en: Unterschied zwischen den Versionen

Aus expecco Wiki (Version 2.x)
Zur Navigation springen Zur Suche springen
Zeile 1: Zeile 1:
== Introduction ==
== Introduction ==


Workspaces ("Notepads") are simple text-editor windows which can also evaluate code. These can be used to prepare or inspect test-data, texts and similar. They also provide a calculator and scripting-language capability: you can type in an expression (expressed as Smalltalk or JavaScript code fragment) and evaluate it. Finally, they can be used as "PostIt-Note", to remember fragments of text or code.
Workspaces ("''Notepads''") are simple text-editor windows which can also evaluate code. These can be used to prepare or inspect test-data, texts and similar. They also provide a calculator and scripting-language capability: you can type in an expression (expressed as Smalltalk or JavaScript code fragment) and evaluate it. Finally, they can be used as "PostIt-Note", to remember fragments of text or code.


Workspaces are very useful to compute test-vectors, hex- or binary numbers or to generate string data, which can be copy-pasted into a freeze-value, an attachment or (using the [[Tools_FileBrowser/en|File Browser]]) into a file.
Workspaces are very useful to compute test-vectors, hex- or binary numbers or to generate string data, which can be copy-pasted into a freeze-value, an attachment or (using the [[Tools_FileBrowser/en|File Browser]]) into a file.

Version vom 17. April 2025, 13:46 Uhr

Introduction[Bearbeiten]

Workspaces ("Notepads") are simple text-editor windows which can also evaluate code. These can be used to prepare or inspect test-data, texts and similar. They also provide a calculator and scripting-language capability: you can type in an expression (expressed as Smalltalk or JavaScript code fragment) and evaluate it. Finally, they can be used as "PostIt-Note", to remember fragments of text or code.

Workspaces are very useful to compute test-vectors, hex- or binary numbers or to generate string data, which can be copy-pasted into a freeze-value, an attachment or (using the File Browser) into a file.

The following screenshot displays a script/code fragment being evaluated:

Notepad1.png

The most useful functions are "DoIt", "PrintIt" and "InspectIt";
all of which evaluate the selected text as a code fragment. If no text is selected, the current cursor line is evaluated.

"PrintIt" will paste the result into the notepad and "InspectIt" will open an inspector (data viewer) on it. Finally, "DoIt" will simply evaluate it, but do nothing with the result.

All of these functions are found in the toolbar AND in the context menu (right button menu).
There are also convenient keyboard shortcuts "CTRL-d" for DoIt, "CTRL-p" for PrintIt and "CTRL-q" for InspectIt. InspectIt shows the result object's internal state (i.e. its private slots) and its class; so you can take a look at the methods (functions) which are provided by the object.

Multiple Tabs[Bearbeiten]

Workspaces support multiple tabs. Click on the "Add Page" button in the toolbar or one of the "Pages" menu functions, to get another tab.

Timer Functions[Bearbeiten]

There is also a Stopwatch and an AlarmTimer found in the Tab-Page menu. Use them for simple measuring tasks, or to get a timed feedback (for example, to get reminded of something to do or check during a long running test-task). The Alarm-Timer can be configured to ring after a time-period or at a final alarm time (good as a tea-timer !).

Snippet Management[Bearbeiten]

All text editors inside expecco share a common snippet database. Snippets are little text fragments which can be quickly pasted into any text editor by pressing some abbreviation followed by ALT-SPACE. For example, a programmer who often needs the string "self" to be typed in, might want to attach the word "self " to the snipplet-abreviation "s" and get the full string via "s"-ALT-SPACE. A number of predefined snippets (mostly for programmers) can be found and managed in the snippet manager. You may want to customize them according to your domain's requirements.

Collecting Text from Various Places[Bearbeiten]

A very common task is to collect text-fragments via copy-paste from various places (such as different input fields of a tested GUI application) and place them as a single line collection into a freeze-value, attachment or other string-field. The "Autofetch Selection" option found in the "Edit" menu does exactly that for you: it monitors the clipboard, and appends every copied string (from any other application) into the workspace's text area.

Sorting[Bearbeiten]

Under the editor's right-button-menu, you will find various items under "More" → "Tools" → "Sort". These operate on the currently selected line-range. For example, to sort a number of lines, select them, and apply the "Sort Lines" function.

Generating Unique IDs[Bearbeiten]

The right-button-menu also provides a function to generate globally unique IDs (GUIDs or UUIDs). Try "More" → "More" → "Insert new UUID"

Code Evaluation[Bearbeiten]

To evaluate a piece of code, select it, and apply the "DoIt" menu function. Use "PrintIt" to paste the result. Finally "InspectIt" will open an inspector window on the result.

Workspaces include code interpreters for JavaScript, Smalltalk and other languages (depending on the expecco version, more languages may be available).

The syntax of the interpreter can be changed via the main-menu (under the "Workspace"-item), or via the right-click-menu in the lower-right syntax indicator field. Notice that the syntax-indicator field's visibility can be controlled via the "View"-menu's "Show Info" item. You may have to turn it on first.

For example, to compute the square-root of the number 2, type (assuming that JavaScript syntax is selected):

2.sqrt()

or:

Math.sqrt(2)

apply "PrintIt" (while either the expression's text is selected or the cursor is in the line), to get the result pasted at the current text-cursor position.
The result will be already selected, so you can Cut or Copy it immediately for further use.

The above example works when "JavaScript" is set as syntax. With Smalltalk syntax, you would have to enter:

2 sqrt

Variables[Bearbeiten]

New variables are automatically created as required. For example, when evaluating the Smalltalk expression:

a := 10

then, a variable "a" will be created and can be later referred to, for example in:

b := a + 20

The variable's value will be retained until the workspace is closed. I.e. be careful, if you keep big data chunks in a variable (say megabytes of test data). this may eat up memory.

By default, these variables are ONLY known inside the workspace where they were initially created. If you open a second workspace, the "a" from the other workspace will not be visible. You can change this behavior via the "Workspace" = "Autodefine Variables" menu item:

  • as global workspace variable
the variable will be visible in all workspace windows
  • as local workspace variable
only visible locally (the default)
  • as doIt variable
only visible within one single doIt evaluation

Physic/Math Language[Bearbeiten]

When switching to the "Physic/Math" language, you can enter mathematical and physical expressions like:

10 Ω * 5 A

or equations like:

x^2 + 3x = 4

Workspace math.png

Depending on your keyboard mapping, special characters for units (such as the "Ω" above) are available via ALT-key combinations or not. If not, you can enter them via the "More" - "Special Characters" function in the right button menu.

Notice:
Basically, this is the same functionality as described in the "Physical Values Documentation". However, Math language expressions have a standard operator precedence (eg. '*' higher than '+'), they support implicit product expressions (eg. "3x") and can also include special unit symbols (eg. "Ω" instead of the Smalltalk "ohm").
In Smalltalk, the above would be:

10 ohm * 5 ampere
'x^2 + 3x = 4' asPhysicExpression solve

More Features[Bearbeiten]

The expecco Notepad as described here is a somewhat stripped-down version of the full Smalltalk-Workspace application. In order to be more "beginner friendly", it has smaller menus and less functions as the full featured version.

You will find many more features (text-filters, variables, languages etc.) in this application, which can be opened via:

Smalltalk.WorkspaceApplication.open()

or (if you prefer Smalltalk), with:

Smalltalk::WorkspaceApplication open

or by changing the default notepad in the "Settings" → "Internal Tools" dialog to "Smalltalk".

Scripting in a Workspace[Bearbeiten]

When you are more familiar with Smalltalk/JavaScript functions, they are also useful to perform bulk operations on files, which are otherwise typically performed with shell or batch scripts. The advantage is that those are portable between Unix/Linux and Windows.

Here is a sample script, which walks down a directory hierarchy, looks for files named ".cvsignore", modifies them if a particular line is missing and checks them into the source repository (in this example into a CVS repository):

'.' asFilename withAllDirectoriesDo:[:dir |
   |text idx|

   "/ for each file named ".cvsignore" 
   dir isSymbolicLink ifFalse:[
       (dir / '.cvsignore') exists ifTrue:[
           text := (dir / '.cvsignore') contents.
           "/ look for a line
           (idx := text indexOf:'objmingw') ~~ 0 ifTrue:[
               "/ look or another
               (text includes:'objmingw32') ifFalse:[
                   "/ if missing, add it 
                   Transcript showCR:(dir / '.cvsignore') name.
                   text add:'objmingw32' afterIndex:idx.
                   (dir / '.cvsignore') contents:text.
                   "/ and check it in
                   OperatingSystem 
                      executeCommand:'cvs commit -m "x" .cvsignore' 
                      outputTo:Transcript 
                      errorTo:Transcript inDirectory:dir.
               ]
           ]
       ]
   ]
].

You can add scripts to your private "MyWorkspace" and use fragments as templates.

See Also[Bearbeiten]

The workspace's full documentation is part of the official Smalltalk/X Online Documentation.

 


Back to Online Documentation.
Back to Tools.



Copyright © 2014-2024 eXept Software AG