Initial data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 72d218235f
commit f23f22d71c
199087 changed files with 3378941 additions and 0 deletions

View file

@ -0,0 +1,3 @@
---
from: http://rosettacode.org/wiki/User_input/Text
note: Text processing

View file

@ -0,0 +1,11 @@
{{selection|Short Circuit|Console Program Basics}}
[[Category:Basic language learning]]
[[Category:Keyboard input]]
[[Category:Simple]]
;Task:
Input a string and the integer   '''75000'''   from the text console.
See also: [[User input/Graphical]]
<br><br>

View file

@ -0,0 +1,2 @@
V string = input(Input a string: )
V number = Float(input(Input a number: ))

View file

@ -0,0 +1,67 @@
//Consts
.equ BUFFERSIZE, 100
.equ STDIN, 0 // linux input console
.equ STDOUT, 1 // linux output console
.equ READ, 63
.equ WRITE, 64
.equ EXIT, 93
.data
enterText: .asciz "Enter text: "
carriageReturn: .asciz "\n"
//Read Buffer
.bss
buffer: .skip BUFFERSIZE
.text
.global _start
quadEnterText: .quad enterText
quadBuffer: .quad buffer
quadCarriageReturn: .quad carriageReturn
writeMessage:
mov x2,0 // reset size counter to 0
checkSize: // get size of input
ldrb w1,[x0,x2] // load char with offset of x2
add x2,x2,#1 // add 1 char read legnth
cbz w1,output // if char found
b checkSize // loop
output:
mov x1,x0 // move string address into system call func parm
mov x0,STDOUT
mov x8,WRITE
svc 0 // trigger system write
ret
_start:
//Output enter text
ldr x0,quadEnterText // load enter message
bl writeMessage // output enter message
//Read User Input
mov x0,STDIN // linux input console
ldr x1,quadBuffer // load buffer address
mov x2,BUFFERSIZE // load buffer size
mov x8,READ // request to read data
svc 0 // trigger system read input
//Output User Message
mov x2, #0 // prep end of string
ldr x1,quadBuffer // load buffer address
strb w2,[x1, x0] // store x2 0 byte at the end of input string, offset x0
ldr x0,quadBuffer // load buffer address
bl writeMessage
//Output newline
ldr x0,quadCarriageReturn
bl writeMessage
//End Program
mov x0, #0 // return code
mov x8, #EXIT // request to exit program
svc 0 // trigger end of program

View file

@ -0,0 +1,5 @@
print("Enter a string: ");
STRING s := read string;
print("Enter a number: ");
INT i := read int;
~

View file

@ -0,0 +1,8 @@
begin
string(80) s;
integer n;
write( "Enter a string > " );
read( s );
write( "Enter an integer> " );
read( n )
end.

View file

@ -0,0 +1,2 @@
str
int

View file

@ -0,0 +1,149 @@
/* ARM assembly Raspberry PI */
/* program inputText.s */
/* Constantes */
.equ BUFFERSIZE, 100
.equ STDIN, 0 @ Linux input console
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ READ, 3 @ Linux syscall
.equ WRITE, 4 @ Linux syscall
/* Initialized data */
.data
szMessDeb: .asciz "Enter text : \n"
szMessNum: .asciz "Enter number : \n"
szCarriageReturn: .asciz "\n"
/* UnInitialized data */
.bss
sBuffer: .skip BUFFERSIZE
/* code section */
.text
.global main
main: /* entry of program */
push {fp,lr} /* saves 2 registers */
ldr r0,iAdrszMessDeb
bl affichageMess
mov r0,#STDIN @ Linux input console
ldr r1,iAdrsBuffer @ buffer address
mov r2,#BUFFERSIZE @ buffer size
mov r7, #READ @ request to read datas
swi 0 @ call system
ldr r1,iAdrsBuffer @ buffer address
mov r2,#0 @ end of string
strb r2,[r1,r0] @ store byte at the end of input string (r0 contains number of characters)
ldr r0,iAdrsBuffer @ buffer address
bl affichageMess
ldr r0,iAdrszCarriageReturn
bl affichageMess
ldr r0,iAdrszMessNum
bl affichageMess
mov r0,#STDIN @ Linux input console
ldr r1,iAdrsBuffer @ buffer address
mov r2,#BUFFERSIZE @ buffer size
mov r7, #READ @ request to read datas
swi 0 @ call system
ldr r1,iAdrsBuffer @ buffer address
mov r2,#0 @ end of string
strb r2,[r1,r0] @ store byte at the end of input string (r0
@
ldr r0,iAdrsBuffer @ buffer address
bl conversionAtoD @ conversion string in number in r0
100: /* standard end of the program */
mov r0, #0 @ return code
pop {fp,lr} @restaur 2 registers
mov r7, #EXIT @ request to exit program
swi 0 @ perform the system call
iAdrszMessDeb: .int szMessDeb
iAdrszMessNum: .int szMessNum
iAdrsBuffer: .int sBuffer
iAdrszCarriageReturn: .int szCarriageReturn
/******************************************************************/
/* display text with size calculation */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
push {fp,lr} /* save registres */
push {r0,r1,r2,r7} /* save others registers */
mov r2,#0 /* counter length */
1: /* loop length calculation */
ldrb r1,[r0,r2] /* read octet start position + index */
cmp r1,#0 /* if 0 its over */
addne r2,r2,#1 /* else add 1 in the length */
bne 1b /* and loop */
/* so here r2 contains the length of the message */
mov r1,r0 /* address message in r1 */
mov r0,#STDOUT /* code to write to the standard output Linux */
mov r7, #WRITE /* code call system "write" */
swi #0 /* call systeme */
pop {r0,r1,r2,r7} /* restaur others registers */
pop {fp,lr} /* restaur des 2 registres */
bx lr /* return */
/******************************************************************/
/* Convert a string to a number stored in a registry */
/******************************************************************/
/* r0 contains the address of the area terminated by 0 or 0A */
/* r0 returns a number */
conversionAtoD:
push {fp,lr} @ save 2 registers
push {r1-r7} @ save others registers
mov r1,#0
mov r2,#10 @ factor
mov r3,#0 @ counter
mov r4,r0 @ save address string -> r4
mov r6,#0 @ positive sign by default
mov r0,#0 @ initialization to 0
1: /* early space elimination loop */
ldrb r5,[r4,r3] @ loading in r5 of the byte located at the beginning + the position
cmp r5,#0 @ end of string -> end routine
beq 100f
cmp r5,#0x0A @ end of string -> end routine
beq 100f
cmp r5,#' ' @ space ?
addeq r3,r3,#1 @ yes we loop by moving one byte
beq 1b
cmp r5,#'-' @ first character is -
moveq r6,#1 @ 1 -> r6
beq 3f @ then move on to the next position
2: /* beginning of digit processing loop */
cmp r5,#'0' @ character is not a number
blt 3f
cmp r5,#'9' @ character is not a number
bgt 3f
/* character is a number */
sub r5,#48
ldr r1,iMaxi @ check the overflow of the register
cmp r0,r1
bgt 99f @ overflow error
mul r0,r2,r0 @ multiply par factor 10
add r0,r5 @ add to r0
3:
add r3,r3,#1 @ advance to the next position
ldrb r5,[r4,r3] @ load byte
cmp r5,#0 @ end of string -> end routine
beq 4f
cmp r5,#0x0A @ end of string -> end routine
beq 4f
b 2b @ loop
4:
cmp r6,#1 @ test r6 for sign
moveq r1,#-1
muleq r0,r1,r0 @ if negatif, multiply par -1
b 100f
99: /* overflow error */
ldr r0,=szMessErrDep
bl affichageMess
mov r0,#0 @ return zero if error
100:
pop {r1-r7} @ restaur other registers
pop {fp,lr} @ restaur 2 registers
bx lr @return procedure
/* constante program */
iMaxi: .int 1073741824
szMessErrDep: .asciz "Too large: overflow 32 bits.\n"

View file

@ -0,0 +1,5 @@
~/src/opt/run $ awk 'BEGIN{printf "enter a string: "}{s=$0;i=$0+0;print "ok,"s"/"i}'
enter a string: hello world
ok,hello world/0
75000
ok,75000/75000

View file

@ -0,0 +1,23 @@
INCLUDE "H6:REALMATH.ACT"
PROC Main()
CHAR ARRAY sUser(255)
REAL r75000,rUser
Put(125) PutE() ;clear the screen
ValR("75000",r75000)
Print("Please enter a text: ")
InputS(sUser)
DO
Print("Please enter number ")
PrintR(r75000) Print(": ")
InputR(rUser)
UNTIL RealEqual(rUser,r75000)
OD
PutE()
Print("Text: ") PrintE(sUser)
Print("Number: ") PrintRE(rUser)
RETURN

View file

@ -0,0 +1,14 @@
function Get_String return String is
Line : String (1 .. 1_000);
Last : Natural;
begin
Get_Line (Line, Last);
return Line (1 .. Last);
end Get_String;
function Get_Integer return Integer is
S : constant String := Get_String;
begin
return Integer'Value (S);
-- may raise exception Constraint_Error if value entered is not a well-formed integer
end Get_Integer;

View file

@ -0,0 +1,2 @@
My_String : String := Get_String;
My_Integer : Integer := Get_Integer;

View file

@ -0,0 +1,15 @@
with Ada.Text_IO, Ada.Integer_Text_IO;
procedure User_Input is
I : Integer;
begin
Ada.Text_IO.Put ("Enter a string: ");
declare
S : String := Ada.Text_IO.Get_Line;
begin
Ada.Text_IO.Put_Line (S);
end;
Ada.Text_IO.Put ("Enter an integer: ");
Ada.Integer_Text_IO.Get(I);
Ada.Text_IO.Put_Line (Integer'Image(I));
end User_Input;

View file

@ -0,0 +1,18 @@
with
Ada.Text_IO,
Ada.Integer_Text_IO,
Ada.Strings.Unbounded,
Ada.Text_IO.Unbounded_IO;
procedure User_Input2 is
S : Ada.Strings.Unbounded.Unbounded_String;
I : Integer;
begin
Ada.Text_IO.Put("Enter a string: ");
S := Ada.Strings.Unbounded.To_Unbounded_String(Ada.Text_IO.Get_Line);
Ada.Text_IO.Put_Line(Ada.Strings.Unbounded.To_String(S));
Ada.Text_IO.Unbounded_IO.Put_Line(S);
Ada.Text_IO.Put("Enter an integer: ");
Ada.Integer_Text_IO.Get(I);
Ada.Text_IO.Put_Line(Integer'Image(I));
end User_Input2;

View file

@ -0,0 +1,12 @@
#include <flow.h>
#import lib/input.bas.lib
#include include/flow-input.h
DEF-MAIN(argv,argc)
CLR-SCR
MSET( número, cadena )
LOCATE(2,2), PRNL( "Input an string : "), LOC-COL(20), LET( cadena := READ-STRING( cadena ) )
LOCATE(3,2), PRNL( "Input an integer: "), LOC-COL(20), LET( número := INT( VAL(READ-NUMBER( número )) ) )
LOCATE(5,2), PRNL( cadena, "\n ",número )
END

View file

@ -0,0 +1,2 @@
10 INPUT "ENTER A STRING: "; S$
20 INPUT "ENTER A NUMBER: "; I : I = INT(I)

View file

@ -0,0 +1,4 @@
str: input "Enter a string: "
num: to :integer input "Enter an integer: "
print ["Got:" str "," num]

View file

@ -0,0 +1,7 @@
DllCall("AllocConsole")
FileAppend, please type something`n, CONOUT$
FileReadLine, line, CONIN$, 1
msgbox % line
FileAppend, please type '75000'`n, CONOUT$
FileReadLine, line, CONIN$, 1
msgbox % line

View file

@ -0,0 +1,23 @@
TrayTip, Input:, Type a string:
Input(String)
TrayTip, Input:, Type an int:
Input(Int)
TrayTip, Done!, Input was recieved.
Msgbox, You entered "%String%" and "%Int%"
ExitApp
Return
Input(ByRef Output)
{
Loop
{
Input, Char, L1, {Enter}{Space}
If ErrorLevel contains Enter
Break
Else If ErrorLevel contains Space
Output .= " "
Else
Output .= Char
TrayTip, Input:, %Output%
}
}

View file

@ -0,0 +1,35 @@
Disp "String:"
input→A
length(A)→L
.Copy the string to a safe location
Copy(A,L₁,L)
.Display the string
Disp "You entered:",i
For(I,0,L-1)
Disp {L₁+I}►Char
End
Disp i
Disp "Integer:",i
input→B
length(B)→L
.Parse the string and convert to an integer
0→C
For(I,0,L-1)
{B+I}-'0'→N
If N>10
.Error checking
Disp "Not a number",i
Return
End
C*10+N→C
End
.Display and check the integer
Disp "You entered:",i,C►Dec,i
If C≠7500
Disp "That isn't 7500"
End

View file

@ -0,0 +1,2 @@
INPUT "Enter a string"; s$
INPUT "Enter a number: ", i%

View file

@ -0,0 +1,6 @@
input string "Please enter a string: ", s
do
input "Please enter 75000 : ", i
until i = 75000
print
print s, i

View file

@ -0,0 +1,5 @@
INPUT LINE "Enter a string: " string$
INPUT "Enter a number: " number
PRINT "String = """ string$ """"
PRINT "Number = " ; number

View file

@ -0,0 +1,3 @@
@echo off
set /p var=
echo %var% 75000

View file

@ -0,0 +1,3 @@
<>:v:"Enter a string: "
^,_ >~:1+v
^ _@

View file

@ -0,0 +1,2 @@
<>:v:"Enter a number: "
^,_ & @

View file

@ -0,0 +1,11 @@
( doit
= out'"Enter a string"
& get':?mystring
& whl
' ( out'"Enter a number"
& get':?mynumber
& !mynumber:~#
& out'"I said:\"a number\"!"
)
& out$(mystring is !mystring \nmynumber is !mynumber \n)
);

View file

@ -0,0 +1,16 @@
#include <iostream>
#include <string>
using namespace std;
int main()
{
// while probably all current implementations have int wide enough for 75000, the C++ standard
// only guarantees this for long int.
long int integer_input;
string string_input;
cout << "Enter an integer: ";
cin >> integer_input;
cout << "Enter a string: ";
cin >> string_input;
return 0;
}

View file

@ -0,0 +1 @@
cin >> string_input;

View file

@ -0,0 +1 @@
getline(cin, string_input);

View file

@ -0,0 +1,17 @@
using System;
namespace C_Sharp_Console {
class example {
static void Main() {
string word;
int num;
Console.Write("Enter an integer: ");
num = Console.Read();
Console.Write("Enter a String: ");
word = Console.ReadLine();
}
}
}

View file

@ -0,0 +1,22 @@
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
// Get a string from stdin
char str[BUFSIZ];
puts("Enter a string: ");
fgets(str, sizeof(str), stdin);
// Get 75000 from stdin
long num;
char buf[BUFSIZ];
do
{
puts("Enter 75000: ");
fgets(buf, sizeof(buf), stdin);
num = strtol(buf, NULL, 10);
} while (num != 75000);
return EXIT_SUCCESS;
}

View file

@ -0,0 +1,25 @@
#include <gadget/gadget.h>
LIB_GADGET_START
Main
Cls;
String text;
int number=0;
At 5,5; Print "Enter text : ";
Atrow 7; Print "Enter 75000: ";
Atcol 20;
Atrow 5; Fn_let(text, Input ( text, 30 ) );
Free secure text;
Atrow 7; Stack{
while (number!=75000 )
/*into stack, Input() not need var*/
number = Str2int( Input ( NULL, 6 ) );
}Stack_off;
Prnl;
End

View file

@ -0,0 +1,17 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Get-Input.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 Input-String PIC X(30).
01 Input-Int PIC 9(5).
PROCEDURE DIVISION.
DISPLAY "Enter a string:"
ACCEPT Input-String
DISPLAY "Enter a number:"
ACCEPT Input-Int
GOBACK
.

View file

@ -0,0 +1,12 @@
shared void run() {
print("enter any text here");
value text = process.readLine();
print(text);
print("enter the number 75000 here");
if (is Integer number = Integer.parse(process.readLine() else "")) {
print("``number == 75k then number else "close enough"``");
}
else {
print("That was not a number per se.");
}
}

View file

@ -0,0 +1,4 @@
(import '(java.util Scanner))
(def scan (Scanner. *in*))
(def s (.nextLine scan))
(def n (.nextInt scan))

View file

@ -0,0 +1,8 @@
10 input "what is a word i should remember";a$
20 print "thank you."
30 input "will you please type the number 75000";nn
40 if nn<>75000 then print "i'm sorry, that's not right.":goto 30
50 print "thank you.":print "you provided the following values:"
60 print a$
70 print nn
80 end

View file

@ -0,0 +1,9 @@
(format t "Enter some text: ")
(let ((s (read-line)))
(format t "You entered ~s~%" s))
(format t "Enter a number: ")
(let ((n (read)))
(if (numberp n)
(format t "You entered ~d.~%" n)
(format t "That was not a number.")))

View file

@ -0,0 +1,7 @@
puts "You entered: #{gets}"
begin
puts "You entered: #{gets.not_nil!.chomp.to_i}"
rescue ex
puts ex
end

View file

@ -0,0 +1,13 @@
import std.stdio;
void main() {
long number;
write("Enter an integer: ");
readf("%d", &number);
char[] str;
write("Enter a string: ");
readf(" %s\n", &str);
writeln("Read in '", number, "' and '", str, "'");
}

View file

@ -0,0 +1,26 @@
import 'dart:io' show stdout, stdin;
main() {
stdout.write('Enter a string: ');
final string_input = stdin.readLineSync();
int number_input;
do {
stdout.write('Enter the number 75000: ');
var number_input_string = stdin.readLineSync();
try {
number_input = int.parse(number_input_string);
if (number_input != 75000)
stdout.writeln('$number_input is not 75000!');
} on FormatException {
stdout.writeln('$number_input_string is not a valid number!');
} catch ( e ) {
stdout.writeln(e);
}
} while ( number_input != 75000 );
stdout.writeln('input: $string_input\nnumber: $number_input');
}

View file

@ -0,0 +1,22 @@
program UserInputText;
{$APPTYPE CONSOLE}
uses SysUtils;
var
s: string;
lStringValue: string;
lIntegerValue: Integer;
begin
WriteLn('Enter a string:');
Readln(lStringValue);
repeat
WriteLn('Enter the number 75000');
Readln(s);
lIntegerValue := StrToIntDef(s, 0);
if lIntegerValue <> 75000 then
Writeln('Invalid entry: ' + s);
until lIntegerValue = 75000;
end.

View file

@ -0,0 +1,10 @@
write "Enter a string: "
a$ = input
print ""
repeat
write "Enter the number 75000: "
h = number input
print ""
until h = 75000
.
print a$ & " " & h

View file

@ -0,0 +1,9 @@
import extensions;
public program()
{
var num := new Integer();
console.write:"Enter an integer: ".loadLineTo:num;
var word := console.write:"Enter a String: ".readLine()
}

View file

@ -0,0 +1,6 @@
a = IO.gets("Enter a string: ") |> String.strip
b = IO.gets("Enter an integer: ") |> String.strip |> String.to_integer
f = IO.gets("Enter a real number: ") |> String.strip |> String.to_float
IO.puts "String = #{a}"
IO.puts "Integer = #{b}"
IO.puts "Float = #{f}"

View file

@ -0,0 +1,2 @@
{ok, [String]} = io:fread("Enter a string: ","~s").
{ok, [Number]} = io:fread("Enter a number: ","~d").

View file

@ -0,0 +1 @@
String = io:get_line("Enter a string: ").

View file

@ -0,0 +1,9 @@
include get.e
sequence s
atom n
s = prompt_string("Enter a string:")
puts(1, s & '\n')
n = prompt_number("Enter a number:",{})
printf(1, "%d", n)

View file

@ -0,0 +1,11 @@
open System
let ask_for_input s =
printf "%s (End with Return): " s
Console.ReadLine()
[<EntryPoint>]
let main argv =
ask_for_input "Input a string" |> ignore
ask_for_input "Enter the number 75000" |> ignore
0

View file

@ -0,0 +1,3 @@
[[^$' =~][,]#,]w:
[0[^'0-$$9>0@>|~][\10*+]#%]d:
w;! d;!.

View file

@ -0,0 +1,4 @@
"Enter a string: " write
readln
"Enter a number: " write
readln string>number

View file

@ -0,0 +1,4 @@
printl("Enter a string:")
str = input()
printl("Enter a number:")
n = int(input())

View file

@ -0,0 +1,18 @@
class Main
{
public static Void main ()
{
Env.cur.out.print ("Enter a string: ").flush
str := Env.cur.in.readLine
echo ("Entered :$str:")
Env.cur.out.print ("Enter 75000: ").flush
Int n
try n = Env.cur.in.readLine.toInt
catch (Err e)
{
echo ("You had to enter a number")
return
}
echo ("Entered :$n: which is " + ((n == 75000) ? "correct" : "wrong"))
}
}

View file

@ -0,0 +1,3 @@
: INPUT$ ( n -- addr n )
PAD SWAP ACCEPT
PAD SWAP ;

View file

@ -0,0 +1,4 @@
: INPUT# ( -- u true | false )
0. 16 INPUT$ DUP >R
>NUMBER NIP NIP
R> <> DUP 0= IF NIP THEN ;

View file

@ -0,0 +1,2 @@
: INPUT# ( -- n true | d 1 | false )
16 INPUT$ SNUMBER? ;

View file

@ -0,0 +1,3 @@
: INPUT# ( -- n true | false )
16 INPUT$ NUMBER? NIP
DUP 0= IF NIP THEN ;

View file

@ -0,0 +1,8 @@
: input#
begin
refill drop bl parse-word ( a n)
number error? ( n f)
while ( n)
drop ( --)
repeat ( n)
;

View file

@ -0,0 +1,6 @@
: TEST
." Enter your name: " 80 INPUT$ CR
." Hello there, " TYPE CR
." Enter a number: " INPUT# CR
IF ." Your number is " .
ELSE ." That's not a number!" THEN CR ;

View file

@ -0,0 +1,7 @@
character(20) :: s
integer :: i
print*, "Enter a string (max 20 characters)"
read*, s
print*, "Enter the integer 75000"
read*, i

View file

@ -0,0 +1,11 @@
' FB 1.05.0 Win64
Dim s As String
Dim i AS Integer
Input "Please enter a string : "; s
Do
Input "Please enter 75000 : "; i
Loop Until i = 75000
Print
Print s, i
Sleep

View file

@ -0,0 +1,2 @@
s = input["Enter a string: "]
i = parseInt[input["Enter an integer: "]]

View file

@ -0,0 +1,13 @@
extends MainLoop
func _process(_delta: float) -> bool:
printraw("Input a string: ")
var read_line := OS.read_string_from_stdin() # Mote that this retains the newline.
printraw("Input an integer: ")
var read_integer := int(OS.read_string_from_stdin())
print("read_line = %s" % read_line.trim_suffix("\n"))
print("read_integer = %d" % read_integer)
return true # Exit instead of looping

View file

@ -0,0 +1,13 @@
package main
import "fmt"
func main() {
var s string
var i int
if _, err := fmt.Scan(&s, &i); err == nil && i == 75000 {
fmt.Println("good")
} else {
fmt.Println("wrong")
}
}

View file

@ -0,0 +1,38 @@
package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
)
func main() {
in := bufio.NewReader(os.Stdin)
fmt.Print("Enter string: ")
s, err := in.ReadString('\n')
if err != nil {
fmt.Println(err)
return
}
s = strings.TrimSpace(s)
fmt.Print("Enter 75000: ")
s, err = in.ReadString('\n')
if err != nil {
fmt.Println(err)
return
}
n, err := strconv.Atoi(strings.TrimSpace(s))
if err != nil {
fmt.Println(err)
return
}
if n != 75000 {
fmt.Println("fail: not 75000")
return
}
fmt.Println("Good")
}

View file

@ -0,0 +1,2 @@
word = System.in.readLine()
num = System.in.readLine().toInteger()

View file

@ -0,0 +1,9 @@
import System.IO (hFlush, stdout)
main = do
putStr "Enter a string: "
hFlush stdout
str <- getLine
putStr "Enter an integer: "
hFlush stdout
num <- readLn :: IO Int
putStrLn $ str ++ (show num)

View file

@ -0,0 +1,4 @@
print "Enter a string: "
let s scan str
print "Enter a number: "
let n scan int

View file

@ -0,0 +1,10 @@
U8 *s;
s = GetStr("Enter a string: ");
U32 *n;
do {
n = GetStr("Enter 75000: ");
} while(Str2I64(n) != 75000);
Print("Your string: %s\n", s);
Print("75000: %d\n", Str2I64(n));

View file

@ -0,0 +1,2 @@
100 INPUT PROMPT "Enter a number: ":NUM
110 INPUT PROMPT "Enter a string: ":ST$

View file

@ -0,0 +1,10 @@
procedure main ()
writes ("Enter something: ")
s := read ()
write ("You entered: " || s)
writes ("Enter 75000: ")
if (i := integer (read ())) then
write (if (i = 75000) then "correct" else "incorrect")
else write ("you must enter a number")
end

View file

@ -0,0 +1,2 @@
string := File clone standardInput readLine("Enter a string: ")
integer := File clone standardInput readLine("Enter 75000: ") asNumber

View file

@ -0,0 +1,3 @@
require 'misc' NB. load system script
prompt 'Enter string: '
0".prompt 'Enter an integer: '

View file

@ -0,0 +1,14 @@
prompt 'Enter string: ' NB. output string to session
Enter string: Hello World
Hello World
0".prompt 'Enter an integer: ' NB. output integer to session
Enter an integer: 75000
75000
mystring=: prompt 'Enter string: ' NB. store string as noun
Enter string: Hello Rosetta Code
myinteger=: 0".prompt 'Enter an integer: ' NB. store integer as noun
Enter an integer: 75000
mystring;myinteger NB. show contents of nouns
┌──────────────────┬─────┐
│Hello Rosetta Code│75000│
└──────────────────┴─────┘

View file

@ -0,0 +1,11 @@
import java.util.Scanner;
public class GetInput {
public static void main(String[] args) throws Exception {
Scanner s = new Scanner(System.in);
System.out.print("Enter a string: ");
String str = s.nextLine();
System.out.print("Enter an integer: ");
int i = Integer.parseInt(s.next());
}
}

View file

@ -0,0 +1,9 @@
import java.util.Scanner;
public class GetInput {
public static void main(String[] args) {
Scanner stdin = new Scanner(System.in);
String string = stdin.nextLine();
int number = stdin.nextInt();
}
}

View file

@ -0,0 +1,8 @@
WScript.Echo("Enter a string");
var str = WScript.StdIn.ReadLine();
var val = 0;
while (val != 75000) {
WScript.Echo("Enter the integer 75000");
val = parseInt( WScript.StdIn.ReadLine() );
}

View file

@ -0,0 +1,8 @@
print("Enter a string");
var str = readline();
var val = 0;
while (val != 75000) {
print("Enter the integer 75000");
val = parseInt( readline() );
}

View file

@ -0,0 +1,4 @@
"Enter a string: " putchars
stdin fgets
"Enter a number: " putchars
stdin fgets 10 strtol.

View file

@ -0,0 +1,8 @@
def read(int):
null | until( . == int; "Expecting \(int)" | stderr | input);
def read_string:
null | until( type == "string"; "Please enter a string" | stderr | input);
(read_string | "I see the string: \(.)"),
(read(75000) | "I see the expected integer: \(.)")

View file

@ -0,0 +1,13 @@
$ jq -n -r -f User_input.jq
"Please enter a string"
1
"Please enter a string"
"ok"
I see the string: ok
"Expecting 75000"
1
"Expecting 75000"
"ok"
"Expecting 75000"
75000
I see the expected integer: 75000

View file

@ -0,0 +1,11 @@
print("String? ")
y = readline()
println("Your input was \"", y, "\".\n")
print("Integer? ")
y = readline()
try
y = parse(Int, y)
println("Your input was \"", y, "\".\n")
catch
println("Sorry, but \"", y, "\" does not compute as an integer.")
end

View file

@ -0,0 +1,2 @@
System.file.stdout|write("Enter a String ");
string = System.file.stdin|readline();

View file

@ -0,0 +1,11 @@
// version 1.1
fun main(args: Array<String>) {
print("Enter a string : ")
val s = readLine()!!
println(s)
do {
print("Enter 75000 : ")
val number = readLine()!!.toInt()
} while (number != 75000)
}

View file

@ -0,0 +1,12 @@
# User input/text, in LIL
write "Enter a string: "
set text [readline]
set num 0
while {[canread] && $num != 75000} {
write "Enter the number 75000: "
set num [readline]
}
print $text
print $num

View file

@ -0,0 +1,8 @@
HAI 1.4
I HAS A string
GIMMEH string
I HAS A number
GIMMEH number
BTW converts number input to an integer
MAEK number A NUMBR
KTHXBYE

View file

@ -0,0 +1,17 @@
{input
{@ type="text"
placeholder="Please enter a string and dblclick"
ondblclick="alert( 'You wrote « ' +
this.value +
' » and it is ' +
((isNaN(this.value)) ? 'not' : '') +
' a number.' )"
}}
Please enter a string and dblclick
Input: Hello World
Output: You wrote « Hello World » and it is not a number.
Input: 123
Output: You wrote « 123 » and it is a number.

View file

@ -0,0 +1,31 @@
#!/usr/bin/lasso9
define read_input(prompt::string) => {
local(string)
// display prompt
stdout(#prompt)
// the following bits wait until the terminal gives you back a line of input
while(not #string or #string -> size == 0) => {
#string = file_stdin -> readsomebytes(1024, 1000)
}
#string -> replace(bytes('\n'), bytes(''))
return #string -> asstring
}
local(
string,
number
)
// get string
#string = read_input('Enter the string: ')
// get number
#number = integer(read_input('Enter the number: '))
// deliver the result
stdoutnl(#string + ' (' + #string -> type + ') | ' + #number + ' (' + #number -> type + ')')

View file

@ -0,0 +1,2 @@
Input "Enter a string. ";string$
Input "Enter the value 75000.";num

View file

@ -0,0 +1,7 @@
make "input readlist ; in: string 75000
show map "number? :input ; [false true]
make "input readword ; in: 75000
show :input + 123 ; 75123
make "input readword ; in: string 75000
show :input ; string 75000

View file

@ -0,0 +1,16 @@
:- object(user_input).
:- public(test/0).
test :-
repeat,
write('Enter an integer: '),
read(Integer),
integer(Integer),
!,
repeat,
write('Enter an atom: '),
read(Atom),
atom(Atom),
!.
:- end_object.

View file

@ -0,0 +1,4 @@
| ?- user_input::test.
Enter an integer: 75000.
Enter an atom: 'Hello world!'.
yes

View file

@ -0,0 +1,4 @@
print('Enter a string: ')
s = io.stdin:read()
print('Enter a number: ')
i = tonumber(io.stdin:read())

View file

@ -0,0 +1,9 @@
Module CheckIt {
Keyboard "75000"+chr$(13)
Input "Integer:", A%
\\ Input erase keyboard buffer, we can't place in first Keyboard keys for second input
Keyboard "Hello World"+Chr$(13)
Input "String:", A$
Print A%, A$
}
CheckIt

View file

@ -0,0 +1,20 @@
>> input('Input string: ')
Input string: 'Hello'
ans =
Hello
>> input('Input number: ')
Input number: 75000
ans =
75000
>> input('Input number, the number will be stored as a string: ','s')
Input number, the number will be stored as a string: 75000
ans =
75000

View file

@ -0,0 +1,3 @@
alias askmesomething {
echo -a You answered: $input(What's your name?, e)
}

View file

@ -0,0 +1,8 @@
TXTINP
NEW S,N
WRITE "Enter a string: "
READ S,!
WRITE "Enter the number 75000: "
READ N,!
KILL S,N
QUIT

View file

@ -0,0 +1,2 @@
printf("String:"); string_value := readline();
printf("Integer: "); int_value := parse(readline());

View file

@ -0,0 +1,2 @@
mystring = InputString["give me a string please"];
myinteger = Input["give me an integer please"];

View file

@ -0,0 +1,12 @@
string s;
message "write a string: ";
s := readstring;
message s;
message "write a number now: ";
b := scantokens readstring;
if b = 750:
message "You've got it!"
else:
message "Sorry..."
fi;
end

Some files were not shown because too many files have changed in this diff Show more