在福斯中,'expect'读多少个字符?

  • 本文关键字:多少 字符 expect forth
  • 更新时间 :
  • 英文 :


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代替。

相关内容

  • 没有找到相关文章

最新更新