我刚开始使用 Pharo,看来您真正遇到的问题仍然是初学者(包括我自己)的问题。查看您的代码,您似乎希望Transcript
每 5 秒更新一次。以下是如何做到这一点(包括评论以明确某些细微差别)。
| process | "If you're running outside a playground, you should declare the variable, otherwise you should not declare it because it needs to bind to the playground itself"
process := [
100 timesRepeat: [
Transcript show: 'Type an a... '; cr. "I like a newline, hence the cr"
(Delay forSeconds: 5) wait.
"In Pharo 10, the following doesn't work, still need to figure out how to do this"
"(Sensor keyPressed: $a) ifTrue: [ Transcript show: 'you pressed a' ]."
]
] fork.
process terminate. "You can run this to terminate the process inside the playground"
process suspend. "Also possible"
process resume.