Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
14
Task/User-input-Text/Ada/user-input-text-1.adb
Normal file
14
Task/User-input-Text/Ada/user-input-text-1.adb
Normal 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;
|
||||
2
Task/User-input-Text/Ada/user-input-text-2.adb
Normal file
2
Task/User-input-Text/Ada/user-input-text-2.adb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
My_String : String := Get_String;
|
||||
My_Integer : Integer := Get_Integer;
|
||||
15
Task/User-input-Text/Ada/user-input-text-3.adb
Normal file
15
Task/User-input-Text/Ada/user-input-text-3.adb
Normal 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;
|
||||
18
Task/User-input-Text/Ada/user-input-text-4.adb
Normal file
18
Task/User-input-Text/Ada/user-input-text-4.adb
Normal 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;
|
||||
17
Task/User-input-Text/COBOL/user-input-text.cob
Normal file
17
Task/User-input-Text/COBOL/user-input-text.cob
Normal 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
|
||||
.
|
||||
9
Task/User-input-Text/Euphoria/user-input-text.eu
Normal file
9
Task/User-input-Text/Euphoria/user-input-text.eu
Normal 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)
|
||||
2
Task/User-input-Text/PowerShell/user-input-text.ps1
Normal file
2
Task/User-input-Text/PowerShell/user-input-text.ps1
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$string = Read-Host "Input a string"
|
||||
[int]$number = Read-Host "Input a number"
|
||||
27
Task/User-input-Text/Rebol/user-input-text.rebol
Normal file
27
Task/User-input-Text/Rebol/user-input-text.rebol
Normal 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 "'."]
|
||||
2
Task/User-input-Text/Rye/user-input-text.rye
Normal file
2
Task/User-input-Text/Rye/user-input-text.rye
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
num: integer input "Number "
|
||||
str: input "String "
|
||||
Loading…
Add table
Add a link
Reference in a new issue