如何暂停程序执行一段时间?

How to pause program execution for some time?

我在 Windows 上使用 "Red Programming Language" 版本“0.6.4”并制作命令行应用程序。

我不懂红语,很多东西我都不懂。我确实在 (https://doc.red-lang.org/en/) 上查看了 "work in progress" 文档,然后才在这里提问。

在命令提示符 window 关闭之前,我需要在屏幕上看到 "Something, something..." 一段时间(比如说 1 秒)。

Red []

; do something
print "Something, something..."

; pause 1 // not working
; sleep 1 // not working

quit

正如我在 pausesleep 中尝试的代码注释中一样,但我收到错误 Script Error: sleep has no value。怎么让它睡觉?

谢谢。

您要找的函数是WAIT。试试 wait 1.

按照上面@MarkI 的规定使用WAIT 是正确答案。

但我想在下面添加这实际上应该是评论但它看起来格式更好!

探索 Red/Rebol 的最佳方式是通过控制台并利用 HELP

>> help pause
No matching values were found in the global context.

这意味着没有为 PAUSE 定义任何内容(help sleep 也没有定义)。

所以改为引用这个词,它将搜索所有定义的函数文档...

>> help "sleep"
No matching values were found in the global context.

>> help "pause"
No matching values were found in the global context.

仍然没有运气:(

好的,让我们尝试一些相关的东西...

>> help "time"
... long list found items...

现在 returns 所有在其函数 spec/docs 中与 "time" 有某种联系的函数。在此列表中是 WAIT 函数。然而,另一个帮助清楚地表明了这一点...

>> help "duration"
     wait            native!       Waits for a duration in seconds or specified time.

现在我们有了...

>> help wait
USAGE:
     WAIT value

DESCRIPTION:
     Waits for a duration in seconds or specified time.
     WAIT is a native! value.

ARGUMENTS:
     value        [number! time! block! none!]

REFINEMENTS:
     /all         => Returns all events in a block

希望对您有所帮助。