-
Notifications
You must be signed in to change notification settings - Fork 0
Language Reference Statement INPUT
The INPUT statement pauses program execution and waits for the user to enter data from the standard input device (the default is the the keyboard) using the input handler. The entered values are parsed, without any type validated or confirmation , and subsequently assigned to one program variable for use during continued execution.
INPUT variable[, variable2, ...]Variables are comma separated.
- Execution of the program pauses, and control is transferred to the terminal interface, awaiting user input.
- The program waits for the user to type characters, concluding input with the new line sequence (For Console as standard input the ENTER).
- The user's input line is parsed into a sequence of values, typically using the comma (
,) as the primary delimiter between values. - The parsed input values are sequentially assigned to the list of specified variables (
$\text{variable}_1, \dots, \text{variable}_n$ ).- Type casting: The interpreter if the input value can be casted to a real number will consider the variable as numeric otherwise as string. Does not checking if a previouse value of the variable was the same type with the new or not.
-
Insufficient Input: If the user provides fewer values than the list of variables (
$\text{input count} < n$ ), the system wait for the missing values. -
Excess Input: If the user provides more values than the list of variables (
$\text{input count} > n$ ), the excess input values are ignored.
| Statement | Purpose |
|---|---|
PRINT |
Send data on the screen or standard output device. Frequently used just before INPUT to display instructions prompt. |
RINPUT |
Used to perform an input request to the RequestObjectHandler. |
print "a:";
input a
print "a:=" + a
print "a,b:";
input a, b
print "a:=" + a
print "b:=" + bInput Handler: The .NET Delegate for Content Delivery
The Input Handler serves as the vital intermediary between the execution of a BASIC INPUT statement and the actual data proviting mechanism. In a modern compiler or interpreter leveraging the .NET framework, the INPUT command does not directly perform screen I/O. Instead, it relies on a .NET delegate to manage content delivery.
This delegate, typically structured as the following code, defines the contract for consuming the generated input text. When a INPUT statement finishes processing its variables, it invokes this registered delegate, passing the finalized numeric or string content as a parameter.
public delegate string InputFunction();The major benefit of this delegate-based approach is complete decoupling. The interpreter engine doesn't need to know if it's running in a command-line environment, a desktop application, or a web server. Developers can easily plug in different handler methods: one to read from to Console.In, another to append text to a graphical user interface (GUI) log window, or even one to enqueue messages for network transmission. This modularity ensures the system is highly testable and incredibly adaptable, allowing the classic INPUT functionality to integrate seamlessly into any sophisticated .NET application architecture.