Jump to content

User input/Text: Difference between revisions

no edit summary
(→‎{{header|D}}: updated to D2)
No edit summary
Line 842:
<lang R>stringval <- readline("String: ")
intval <- as.integer(readline("Integer: "))</lang>
 
=={{header|Rascal}}==
It is possible to use the eclipse IDE to create consoles. However, just as with the graphical input, this will always return a string. This string can subsequently be evaluated. A very simple example would be:
<lang rascal>import util::IDE;
public void InputConsole(){
x = "";
createConsole("Input Console",
"Welcome to the Input Console\nInput\> ",
str (str inp) {x = "<inp == "75000" ? "You entered 75000" : "You entered a string">";
return "<x>\n<inp>\nInput\>";});
}</lang>
This makes it relatively easy to create Domain Specific Languages or to interpret other languages, and create a rascal console for this. For examples with Exp, Func and Lisp, see the online [http://tutor.rascal-mpl.org/Courses/Recipes/Recipes.html#/Courses/Recipes/Languages/Languages.html Language Examples].
 
=={{header|Raven}}==
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.