Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

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,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,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,2 @@
$string = Read-Host "Input a string"
[int]$number = Read-Host "Input a number"

View file

@ -0,0 +1,27 @@
Rebol [
Title: "Textual User Input"
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 it. 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:"
s: ask "string: "
n: ask "number: "
]
; It always pays to be polite...
print rejoin [ "Thank you. Your string was '" s "'."]

View file

@ -0,0 +1,2 @@
num: integer input "Number "
str: input "String "