Rebol 编程/请求
外观
< Rebol 编程
REQUEST str /offset xy /ok /only /confirm /type icon /timeout time
请求对一个简单问题的答案。
REQUEST 是一个函数值。
- str -- (类型:字符串块对象无)
- /offset
- xy -- (类型:任何)
- /ok
- /only
- /confirm
- /type
- icon -- 有效值为:警报,帮助(默认),信息,停止(类型:词语)
- /timeout
- time -- (类型:任何)
request: func [ "Requests an answer to a simple question." str [string! block! object! none!] /offset xy /ok /only /confirm /type icon [word!] {Valid values are: alert, help (default), info, stop} /timeout time /local lay result msg y n c width f img rtn y-key n-key ][ rtn: func [value] [result: value hide-popup] icon: any [icon all [none? icon any [ok timeout] 'info] 'help] lay: either all [object? str in str 'type str/type = 'face] [str] [ if none? str [str: "What is your choice?"] set [y n c] ["Yes" "No" "Cancel"] if confirm [c: none] if ok [y: "OK" n: c: none] if only [y: n: c: none] if block? str [ str: reduce str set [str y n c] str foreach n [str y n c] [ if all [found? get n not string? get n] [set n form get n] ] ] width: any [all [200 >= length? str 280] to-integer (length? str) - 200 / 50 * 20 + 280] layout [f: text bold to-pair reduce [width 1000] str] img: switch/default :icon [ info [info.gif] alert [exclamation.gif] stop [stop.gif] ] [help.gif] result: copy [ across at 0x0 origin 15x10 image img pad 0x12 guide msg: text bold black copy str to-pair reduce [width -1] return pad 4x12 ] y-key: pick "^My" found? ok n-key: pick "^[n" found? confirm append result pick [ [key #"o" [rtn yes] key #" " [rtn yes]] [key #"n" [rtn no] key #"c" [rtn none]] ] found? ok if y [append result [btn-enter 60 y y-key [rtn yes]]] if n [append result [btn 60 silver n n-key [rtn no]]] if c [append result [btn-cancel 60 c escape [rtn none]]] layout result ] result: none either offset [inform/offset/timeout lay xy time] [inform/timeout lay time] result ]