Get a line of edited input from the console input device; store at addr. len1 is the maximum allowed length. len2 is the actual length received.

expect

( addr len -- )

Get and display a line of input from the console; store at addr. (Recommend using accept instead.)

key

( -- char )

Read a character from the console input device.

key?

( -- flag )

True if a key has been typed on the console input device.

parse

( char -- str len )

Parse text from the input buffer delimited by char.

parse-word

( -- str len )

Skip leading spaces and parse text from the input buffer delimited by white space.

word

( char -- pstr )

Collect a string delimited by char from the input buffer and place it as a packed string in memory at pstr. (Recommend using parse instead.)

Comments are used with Forth source code (generally in a text file) to describe the function of the code. The ( (open parenthesis) is the Forth word that begins a comment. Any character up to the closing parenthesis ) is ignored by the Forth interpreter. Stack diagrams are one example of comments using (.

Note -

Remember to follow the( with a space, so that it is recognized as
a Forth word.

\ (backslash) indicates a comment terminated by the end of the line of text.

key waits for a key to be pressed, then returns the ASCII value of that key on the stack.

ascii, used in the form asciix, returns on the stack the numerical code of the character x.

key? looks at the keyboard to see whether the user has recently typed any key. It returns a flag on the stack: true if a key has been pressed and false otherwise. See "Conditional Flags" for a discussion on the use of flags.

Compile an array of bytes from addr of length len, at the top of the dictionary as a packed string.

" ccc"

( -- addr len )

Collect an input stream string, either interpreted or compiled.

." ccc"

Display the string ccc .

.( ccc)

( -- )

Display the string ccc immediately.

-trailing

( addr +n1 -- addr +n2 )

Remove trailing spaces.

bl

( -- char )

ASCII code for the space character; decimal 32.

count

( pstr -- addr +n )

Unpack a packed string.

lcc

( char -- lowercase-char )

Convert a character to lowercase.

left-parse-string

( addr len char -- addrR lenR addrL lenL )

Split a string at char (which is discarded).

pack

( addr len pstr -- pstr )

Store the string addr,len as a packed string at pstr.

upc

( char -- uppercase-char )

Convert a character to uppercase.

Some string commands specify an address (the location in memory where the characters reside) and a length (the number of characters in the string). Other commands use a packed string or pstr, which is a location in memory containing a byte for the length, immediately followed by the characters. The stack diagram for the command indicates which form is used. For example, count converts a packed string to an address-length string.

The command ." is used in the form: ." string". It outputs text immediately when it is encountered by the interpreter. A " (double quotation mark) marks the end of the text string. For example: