Forth-83规范对expect
一词的定义如下:
EXPECT addr +n -- M,83
Receive characters and store each into memory. The transfer
begins at addr proceeding towards higher addresses one byte
per character until either a "return" is received or until
+n characters have been transferred. No more than +n
characters will be stored. The "return" is not stored into
memory. No characters are received or transferred if +n is
zero. All characters actually received and stored into
memory will be displayed, with the "return" displaying as a
space.
因此,它读取到但不包括RETURN或EOL。
但是没有结束符,也没有返回所读的字符数,我怎么知道字符串在哪里结束?
Leo Brodie提到了一个词accept
,它的作用非常相似,它的签名是( addr +n -- +m )
。它会返回读取的字符数,这是我所期望的。但规范中没有。
标准还定义了SPAN
,它告诉您所读取的字符数。
还请注意,在新标准中此函数已废弃,请使用ACCEPT
代替。