在 Basic 中输入关键字
ENTER keyword in Basic
我正在查看一些古老的 1975 年 Basic 代码,并在该行中找到了看起来像关键字的内容:
ENTER #P,B2,B1,C$
.
我知道 B2
, B1
和 C$
都是变量,虽然没有意义 P
可能是一个也是变量。
有谁知道 ENTER
关键字是什么以及这些参数指的是什么?
提前致谢。
ENTER 语句非常晦涩;例如,它没有出现在 David Lien 的 BASIC 手册的 first or third 版本中。
通过搜索“ENTER #P”,我找到了一个包含它的 BASIC 变体:HP 2000/Access BASIC。这本特定手册的日期是 1975 年 9 月,因此它与您正在查看的程序的日期大致相符。
在 HP 2000/Access BASIC(手册的第 2-15 和 11-33 页)中,ENTER 语句是 INPUT 的一种变体,它不提供提示并且还存储有关输入方式和位置的更多信息被提供。井号 (#) 的意义在于它 将用户端口号分配给该变量 。在您的情况下,“用户端口号”分配给变量 P
.
在你的例子中:
P
将分配用户端口号。
B2
是用户必须响应的秒数。如果用户没有响应,则返回值为-256; -257 和 -258 是错误条件。
B1
是用户实际响应的秒数。
C$
是将分配给用户输入的值的变量,如果他们在适当的时间输入它。
手册中似乎没有定义“用户端口号”;但是,从上下文来看,它似乎是用户登录系统的端口。它可以是“0 到 31 范围内”的数字。端口号似乎主要或仅用于日志记录目的。我在手册中没有看到 BASIC 程序可以定位端口号的任何地方。
来自手册:
The ENTER statement provides the program with more control over the input operation. The statement can limit the amount of time allowed to respond with data, provide the program with the actual time taken to respond, indicate whether the data was acceptable, and return the port number of the user's terminal. The port number can be obtained separately, without involving the user at all, or together with a single data value. Data can also be requested without asking for the port number. If a number sign (#) follows the keyword ENTER, then the variable it precedes is assigned the user port number (an integer in the range 0 to 31). Otherwise (or following the port return variable) the first expression is evaluated and rounded to an integer (which must be in the range 1 to 255) specifying the number of seconds permitted the user to respond. No prompt is printed, the program must notify the user that input is expected by a message in a preceding PRINT statement. The variable following the expression is set to the approximate time, in seconds, that the user took to respond. If the constant was not legal, the time is negated. If the allotted time has elapsed, the value -256 is returned; the values -257 and -258 indicate a transmission problem occurred and the user should be asked to respond again. The last variable in the list is assigned the single value which the user is expected to enter. Unlike the INPUT statement, ENTER does not respond to the return (which completes the user's answer) with a line feed.
Examples:
10 ENTER #P
20 ENTER 255,R,A
30 ENTER #P,T1,R,A(I)
幸运的是,P
是本示例中用于端口号的变量,因为它在您的端口号中;否则,搜索将找不到此手册。
我正在查看一些古老的 1975 年 Basic 代码,并在该行中找到了看起来像关键字的内容:
ENTER #P,B2,B1,C$
.
我知道 B2
, B1
和 C$
都是变量,虽然没有意义 P
可能是一个也是变量。
有谁知道 ENTER
关键字是什么以及这些参数指的是什么?
提前致谢。
ENTER 语句非常晦涩;例如,它没有出现在 David Lien 的 BASIC 手册的 first or third 版本中。
通过搜索“ENTER #P”,我找到了一个包含它的 BASIC 变体:HP 2000/Access BASIC。这本特定手册的日期是 1975 年 9 月,因此它与您正在查看的程序的日期大致相符。
在 HP 2000/Access BASIC(手册的第 2-15 和 11-33 页)中,ENTER 语句是 INPUT 的一种变体,它不提供提示并且还存储有关输入方式和位置的更多信息被提供。井号 (#) 的意义在于它 将用户端口号分配给该变量 。在您的情况下,“用户端口号”分配给变量 P
.
在你的例子中:
P
将分配用户端口号。B2
是用户必须响应的秒数。如果用户没有响应,则返回值为-256; -257 和 -258 是错误条件。B1
是用户实际响应的秒数。C$
是将分配给用户输入的值的变量,如果他们在适当的时间输入它。
手册中似乎没有定义“用户端口号”;但是,从上下文来看,它似乎是用户登录系统的端口。它可以是“0 到 31 范围内”的数字。端口号似乎主要或仅用于日志记录目的。我在手册中没有看到 BASIC 程序可以定位端口号的任何地方。
来自手册:
The ENTER statement provides the program with more control over the input operation. The statement can limit the amount of time allowed to respond with data, provide the program with the actual time taken to respond, indicate whether the data was acceptable, and return the port number of the user's terminal. The port number can be obtained separately, without involving the user at all, or together with a single data value. Data can also be requested without asking for the port number. If a number sign (#) follows the keyword ENTER, then the variable it precedes is assigned the user port number (an integer in the range 0 to 31). Otherwise (or following the port return variable) the first expression is evaluated and rounded to an integer (which must be in the range 1 to 255) specifying the number of seconds permitted the user to respond. No prompt is printed, the program must notify the user that input is expected by a message in a preceding PRINT statement. The variable following the expression is set to the approximate time, in seconds, that the user took to respond. If the constant was not legal, the time is negated. If the allotted time has elapsed, the value -256 is returned; the values -257 and -258 indicate a transmission problem occurred and the user should be asked to respond again. The last variable in the list is assigned the single value which the user is expected to enter. Unlike the INPUT statement, ENTER does not respond to the return (which completes the user's answer) with a line feed.
Examples:
10 ENTER #P
20 ENTER 255,R,A
30 ENTER #P,T1,R,A(I)
幸运的是,P
是本示例中用于端口号的变量,因为它在您的端口号中;否则,搜索将找不到此手册。