Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Basic Input from the Command Line in Rebol

I am currently in the process of learning Rebol.

In other languages I know, I can read input from the command line, for example in Java:

Scanner sc = new Scanner(System.in)
sc.nextLine();

In C#

Console.ReadLine();

In C

scanf("%s", s);

I was wondering how one would accomplish the same thing in Rebol.

like image 747
Benjamin Gruenbaum Avatar asked Dec 04 '25 05:12

Benjamin Gruenbaum


2 Answers

You can use the input command to ask for input at the console.

>> name: input
Joe
== "Joe"
like image 53
Adrian Avatar answered Dec 06 '25 23:12

Adrian


The ask function complements input by printing a string prior to requesting input:

age: ask "How old are you? "

It also has a /hide refinement to conceal input:

pass: ask/hide "Enter your password: "

At this time, /hide is not implemented in Rebol 3 alphas

A longer answer (and for intermediate-level at least) would include monitoring the system/ports/input port (you can do source input for how this is done for you)—this can be used in cases where input doesn't originate at the console (such as shell, CGI).

like image 45
rgchris Avatar answered Dec 07 '25 01:12

rgchris