跳转至内容

Rebol 编程/确认

来自维基教科书,开放的书籍,用于开放的世界
CONFIRM question /with choices 

确认用户选择。

CONFIRM 是一个函数值。

  • 问题 -- 提示用户(类型:系列)
  • /with
    • 选项 --(类型:字符串块)

源代码

[编辑 | 编辑源代码]
confirm: func [
    "Confirms a user choice." 
    question [series!] "Prompt to user" 
    /with choices [string! block!] 
    /local yes no
][
    question: form question 
    if with [
        yes: "Yes" 
        no: "No" 
        if string? choices [yes: choices] 
        if all [block? choices not empty? choices] [
            either tail? next choices [yes: choices/1] [set [yes no] choices]
        ] 
        question: reduce [question yes no]
    ] 
    request/confirm question
]
华夏公益教科书