Getting input from the user – input and ask

The easiest way to get an input is to use the input word, as shown in the following code snippet:

;-- see Chapter04/getting-input.red:print "Enter a number: "num: inputprint ["You entered the number" num "with" length? num "digits"]

When interpreted with the console through red getting-input.red or from within the console with do %getting-input.red, we get the following result when the number 89 is entered:

Enter a number:89You entered the number 89 with 2 digits

What is the datatype of num? If we try length? 89 in the console, we get a *** Script Error: length? does not allow integer! for its series argument. But length? "89" returns 2, so num must be of a string! type. Indeed, anything typed into ...

Get Learn Red - Fundamentals of Red now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.