如何在Red 0.6.4(Windows命令行)中实现程序暂停?
How to Add a 1-Second Delay in Red 0.6.4 on Windows
Hey there! I see you're working with Red 0.6.4 on Windows and trying to keep your message visible for 1 second before the command prompt window closes—let me walk you through the fix.
The problem with your current code is that Red doesn't have built-in pause or sleep functions like some other languages. Instead, the correct way to add a delay in Red is using the wait function, which is part of the core language.
Here's your updated, working code:
Red [] ; do something print "Something, something..." wait 1 ; Pauses execution for 1 second quit
A few quick notes to clarify:
wait 1tells the program to halt for exactly 1 second. You can also use decimal values (likewait 0.5) if you need shorter delays.- Since
waitis a core Red function, it won't throw the "has no value" error you got withsleeporpause.
Just swap out your commented-out lines with wait 1, and your message will stay on screen for the desired time before the app exits.
内容的提问来源于stack exchange,提问作者Alex Baban
相关产品推荐
相关产品推荐

