有没有办法制作像 ask 这样的功能,但在 Red 控制台中接受多行?
Is there a way to make a function like ask but which accepts multiple lines in Red console?
使用时
询问"your answer: "
不能粘贴多行。
是否可以控制控制台暂时接受多行?
或者我是否必须创建一个我想避免的 GUI,如果可能的话我不想要任何 GUI。
如果您不想编写自己的 Red/System 例程,粗略的解决方案可能是
ask-2line: function [quest] [
collect/into [
keep ask quest
keep newline
keep ask "[ "
] clear ""
]
>> ask-2line "what: "
what: 1st line
[ second line
== "1st line^/second line"
当然你要定义如何终止输入。
例如
ask-nlines: function [quest] [
collect/into [
while [
not empty? keep ask quest
] [
keep newline
quest: "{ "
]
] clear ""
]
使用时
询问"your answer: "
不能粘贴多行。
是否可以控制控制台暂时接受多行? 或者我是否必须创建一个我想避免的 GUI,如果可能的话我不想要任何 GUI。
如果您不想编写自己的 Red/System 例程,粗略的解决方案可能是
ask-2line: function [quest] [
collect/into [
keep ask quest
keep newline
keep ask "[ "
] clear ""
]
>> ask-2line "what: "
what: 1st line
[ second line
== "1st line^/second line"
当然你要定义如何终止输入。 例如
ask-nlines: function [quest] [
collect/into [
while [
not empty? keep ask quest
] [
keep newline
quest: "{ "
]
] clear ""
]