REBOL Programming/confirm

From Wikibooks, open books for an open world
< REBOL Programming
Jump to: navigation, search

USAGE:[edit]

CONFIRM question /with choices 

DESCRIPTION:[edit]

Confirms a user choice.

CONFIRM is a function value.

ARGUMENTS[edit]

  • question -- Prompt to user (Type: series)

REFINEMENTS[edit]

  • /with
    • choices -- (Type: string block)

SOURCE CODE[edit]

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
]