RosettaCodeData/Task/User-input-Text/XPL0/user-input-text.xpl0

16 lines
618 B
Plaintext

string 0; \use zero-terminated strings, instead of MSb terminated
include c:\cxpl\codes;
int I;
char Name(128); \the keyboard buffer limits input to 128 characters
[Text(0, "What's your name? ");
I:= 0;
loop [Name(I):= ChIn(0); \buffered keyboard input
if Name(I) = $0D\CR\ then quit; \Carriage Return = Enter key
I:= I+1;
];
Name(I):= 0; \terminate string
Text(0, "Howdy "); Text(0, Name); Text(0, "! Now please enter ^"75000^": ");
IntOut(0, IntIn(0)); CrLf(0); \echo the number
]