6.22.4 Miscellaneous output

cr ( ) core “c-r”

Output a newline (of the favourite kind of the host OS). Note that due to the way the Forth command line interpreter inserts newlines, the preferred way to use cr is at the start of a piece of text; e.g., cr ." hello, world".

space ( ) core “space”

Display one space.

spaces ( u –  ) core “spaces”

Display u spaces.

out ( – addr  ) gforth-1.0 “out”

Addr contains a number that tries to give the position of the cursor within the current line on the user output device: It resets to 0 on cr, increases by the number of characters by type and emit, and decreases on backspaces. Unfortunately, it does not take into account tabs, multi-byte characters, or the existence of Unicode characters with width 0 and 2, so it only works for simple cases.

.\" ( compilation ’ccc"’ – ; run-time –  ) gforth-0.6 “dot-backslash-quote”

Like .", but translates C-like \-escape-sequences (see S\").

." ( compilation ’ccc"’ – ; run-time –  ) core “dot-quote”

Compilation: Parse a string ccc delimited by a " (double quote). At run-time, display the string. Interpretation semantics for this word are undefined in standard Forth. Gforth’s interpretation semantics are to display the string.

.( ( compilation&interpretation ’ccc<close-paren>’ –  ) core-ext “dot-paren”

Compilation and interpretation semantics: Parse a string ccc delimited by a ) (right parenthesis). Display the string. This is often used to display progress information during compilation; see examples below.

If you don’t want to worry about wether to use .( hello) or ." hello", you can write "hello" type, which gives you what you usually want (but is less portable to other Forth systems).

As an example, consider the following text, stored in a file test.fs:

.( text-1)
: my-word
  ." text-2" cr
  .( text-3)
  "text-4" type
;

." text-5"
"text-6" type

When you load this code into Gforth, the following output is generated:

include test.fs RET text-1text-3text-5text-6 ok