<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>


EXPECT Search:

In Parsing Words in TurboForth Kernal

Word Name: EXPECT
Type: Standard word
Data Stack Signature: vdp_address length --
Return Stack Signature: --
Availability: V1.0  V1.1  V1.2
Description:

Reads characters from the current input device (either the keyboard, or a disk block).

Example:

Note: this example is for version 1.2

: test ( -- )
  tib @ 80 expect \ get up to 80 characters of text into TIB in VDP RAM
  begin bl word dup while cr type repeat
  2drop ;

test fred bloggs was ere

Output:

fred
bloggs
was
ere

Note: each invocation of WORD copies a word from the Termial Input Buffer (TIB) in VDP memory to a word buffer in CPU memory; thus the address returned by WORD and passed to TYPE in the above example is a CPU memory address.

Comment:

Receive length (up to a maximum of C/L) characters and store each received character into VDP memory.

The transfer begins at vdp_address, proceeding towards higher addresses one byte per character until either a "return" is received or until length or C/L characters have been transferred.

No more than length or C/L characters will be stored. The "return" is not stored into memory.

No characters are received or transferred if length is zero.

On exit, SPAN is set to the number of characters actually received and >IN shall be reset to 0.

See Also: WORD  #TIB  >IN  C/L  SPAN  TIB 

<< Home | About Forth | About TurboForth | Download | Language Reference | Resources | Tutorials | YouTube >>