Terminal control/Restricted width positional input/No wrapping: Difference between revisions
Content added Content deleted
(→{{header|Wren}}: Removed unused function.) |
(Added XPL0 example.) |
||
Line 372: | Line 372: | ||
var res = input.call(3, 5, 8) |
var res = input.call(3, 5, 8) |
||
System.print(res)</lang> |
System.print(res)</lang> |
||
=={{header|XPL0}}== |
|||
<lang XPL0>proc GetData(Col, Row, Width, Str); |
|||
int Col, Row, Width; char Str; |
|||
int I, C; |
|||
string 0; |
|||
[Cursor(Col, Row); |
|||
I:= 0; |
|||
loop [C:= ChIn(1); \Ctrl+C aborts |
|||
if C = $0D \CR\ then |
|||
[Str(I):= 0; \terminate\ quit]; |
|||
if C = $08 \BS\ then |
|||
[if I > 0 then |
|||
[I:= I-1; |
|||
ChOut(0, C); \echo backspace |
|||
ChOut(0, ^ ); \erase character |
|||
ChOut(0, C); \echo backspace |
|||
]; |
|||
]; |
|||
if I<Width & C>=$20 & C<=$7E then |
|||
[ChOut(0, C); \echo character |
|||
Str(I):= C; |
|||
I:= I+1; |
|||
]; |
|||
]; |
|||
]; |
|||
char Str(8+1); |
|||
[ChOut(0, $0C \FF\); \clear screen |
|||
GetData(5, 3, 8, Str); |
|||
Text(0, " |
|||
You entered: "); |
|||
Text(0, Str); |
|||
]</lang> |