跳轉至內容

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
]
華夏公益教科書