Confirm

angerangel edited this page Jan 2, 2013 · 1 revision
Clone this wiki locally

Table of Contents

USAGE

  CONFIRM question /with choices

DESCRIPTION

Confirms a user choice. CONFIRM is a function value.

ARGUMENTS

  • question -- Prompt to user (series!)

REFINEMENTS

  • /with
    • choices (string! block!)

SOURCE

confirm: make function! [  [
    "Confirms a user choice."
    question [series!] "Prompt to user"
    /with choices [string! block!]
    /local response
][
    if all [block? choices 2 < length? choices] [
        cause-error 'script 'invalid-arg mold choices
    ]
    response: ask question
    unless with [choices: [  ["y" "yes"] ["n" "no"] ]]
    case [
        empty? choices [true]
        string? choices [if find/match response choices [true] ]
        2 > length? choices [if find/match response first choices [true] ]
        find first choices response [true]
        find second choices response [false]
    ]
] ]