REBOL [ Title: "Different ways to enter data" ] ;; [---------------------------------------------------------------------------] ;; [ This script uses the various REBOL functions to get operator input, ] ;; [ and then feeds back that input, to show how these various functions ] ;; [ work. ] ;; [---------------------------------------------------------------------------] print "" print "************************************************************************" print " Test the 'ask' function. " print " Enter some input, press the 'enter' key, see the results. " print " Enter 'done' in lower case to move on to the next test. " print "------------------------------------------------------------------------" OP-INPUT: none while [<> OP-INPUT "done"] [ ;; OP-INPUT: none ;; initialization not needed OP-INPUT: ask "Type something and press 'enter', enter 'done' to move on > " print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] ] print "" print "************************************************************************" print " Test the 'input' function. " print " Enter some input, press the 'enter' key, see the results. " print " Enter 'done' in lower case to move on to the next test. " print "------------------------------------------------------------------------" OP-INPUT: none while [<> OP-INPUT "done"] [ prin "Type something and press 'enter', enter 'done' to move on > " OP-INPUT: input print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] ] print "" print "************************************************************************" print " Test the 'input' function with the 'hide' refinement. " print " Enter some input, press the 'enter' key, see the results. " print " Enter 'done' in lower case to move on to the next test. " print "------------------------------------------------------------------------" OP-INPUT: none while [<> OP-INPUT "done"] [ prin "Type something and press 'enter', enter 'done' to move on > " OP-INPUT: input/hide print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] ] print "" print "************************************************************************" print " Test the 'confirm' function. " print " This function obtains a true or false response. Try it. " print "------------------------------------------------------------------------" OP-INPUT: none OP-INPUT: confirm "Click yes or no" print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] print "" print "************************************************************************" print " Test the 'confirm' function with the 'with' refinement. " print " This function obtains a true or false response. Try it. " print "------------------------------------------------------------------------" OP-INPUT: none OP-INPUT: confirm/with "Make your choice" ["Choice 1" "Choice 2"] print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] print "" print "************************************************************************" print " Test the 'choice' function in a simple form. " print " This function has several refinements not demonstrated here. " print "------------------------------------------------------------------------" OP-INPUT: none choose ["Door number 1" "Door number 2" "Door number 3"] func [SELECTION] [ OP-INPUT: SELECTION/text print rejoin [ "Item is selected" newline "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] ] if not OP-INPUT [ print rejoin [ "Item is NOT selected" newline "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] ] print "" print "************************************************************************" print " Test several forms of the 'request' function " print " This function as some refinements not demonstrated here. " print "------------------------------------------------------------------------" OP-INPUT: none OP-INPUT: request "Answer a basic request" print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: request/ok "Answer a simple OK request" print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: request/only "Click 'X' to leave request/only" print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: request/confirm "Answer a request with 'confirm'" print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: request ["Answer a custom request" "One" "Two" "Three"] print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: request/ok/type "Check the alert icon" 'alert print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: request/ok/type "Check the help icon" 'help print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: request/ok/type "Check the info icon" 'info print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: request/ok/type "Check the stop icon" 'stop print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] print "" print "************************************************************************" print " Test the 'alert' function. " print "------------------------------------------------------------------------" OP-INPUT: none OP-INPUT: alert "Basic alert box" print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] OP-INPUT: none OP-INPUT: alert [ "Alert box with two choices" "OK" "Cancel" ] print rejoin [ "Value entered is '" OP-INPUT "' type is " type? OP-INPUT ] print "" print "Test is over, check results then close this window or enter 'quit'." halt