User input/Text: Difference between revisions

→‎{{header|REXX}}: Adding REBOL example.
(pike :D)
(→‎{{header|REXX}}: Adding REBOL example.)
Line 485:
<lang raven>'Input a string: ' print expect as str
'Input an integer: ' print expect 0 prefer as num</lang>
 
=={{header|REBOL}}==
<lang REBOL>EBOL [
Title: "Textual User Input"
Author: oofoe
Date: 2009-12-07
URL: http://rosettacode.org/wiki/User_Input_-_text
]
 
s: n: ""
 
; Because I have several things to check for, I've made a function to
; handle. Note the question mark in the function name, this convention
; is often used in Forth to indicate test of some sort.
 
valid?: func [s n][
error? try [n: to-integer n] ; Ignore error if conversion fails.
all [0 < length? s 75000 = n]]
 
; I don't want to give up until I've gotten something useful, so I
; loop until the user enters valid data.
 
while [not valid? s n][
print "Please enter a string, and the number 75000:"
prin "string: " s: input
prin "number: " n: input
]
 
; It always pays to be polite...
 
print rejoin [ "Thank you. Your string was '" s "'."]</lang>
 
=={{header|REXX}}==
Anonymous user