5.19.8 Line input and conversion

Get a string of up to n1 characters from the user input
device and store it at c-addr. n2 is the length of
the received string. The user indicates the end by pressing
<RET>. Gforth supports all the editing functions available
on the Forth command line (including history and word
completion) in accept.

edit-linec-addr n1 n2 – n3 gforth “edit-line”

edit the string with length n2 in the buffer c-addr
n1, like accept.

Conversion words:

s>number?addr u – d f gforth “s>number?”

converts string addr u into d, flag indicates success

s>unumber?c-addr u – ud flag gforth “s>unumber?”

converts string c-addr u into ud, flag indicates success

>numberud1 c-addr1 u1 – ud2 c-addr2 u2 core “to-number”

Attempt to convert the character string c-addr1 u1 to an
unsigned number in the current number base. The double
ud1 accumulates the result of the conversion to form
ud2. Conversion continues, left-to-right, until the whole
string is converted or a character that is not convertable in
the current number base is encountered (including + or -). For
each convertable character, ud1 is first multiplied by
the value in BASE and then incremented by the value
represented by the character. c-addr2 is the location of
the first unconverted character (past the end of the string if
the whole string was converted). u2 is the number of
unconverted characters in the string. Overflow is not detected.

>floatc-addr u – f:... flag float “to-float”

Actual stack effect: ( c_addr u – r t | f ). Attempt to convert the
character string c-addr u to internal floating-point
representation. If the string represents a valid floating-point number
r is placed on the floating-point stack and flag is
true. Otherwise, flag is false. A string of blanks is a special
case and represents the floating-point number 0.

>float1c-addr u c – f:... flag gforth “to-float1”

Actual stack effect: ( c_addr u c – r t | f ). Attempt to convert the
character string c-addr u to internal floating-point
representation. If the string represents a valid floating-point number
r is placed on the floating-point stack and flag is
true. Otherwise, flag is false. A string of blanks is a special
case and represents the floating-point number 0.

Obsolescent input and conversion words:

convertud1 c-addr1 – ud2 c-addr2 core-ext-obsolescent “convert”

Obsolescent: superseded by >number.

expectc-addr +n – core-ext-obsolescent “expect”

Receive a string of at most +n characters, and store it
in memory starting at c-addr. The string is
displayed. Input terminates when the <return> key is pressed or
+n characters have been received. The normal Gforth line
editing capabilites are available. The length of the string is
stored in span; it does not include the <return>
character. OBSOLESCENT: superceeded by accept.

span– c-addr core-ext-obsolescent “span”

Variable – c-addr is the address of a cell that stores the
length of the last string received by expect. OBSOLESCENT.