I am going over some ancient 1975 Basic code and found what looks like a keyword in the line:
ENTER #P,B2,B1,C$
.
I know that B2
, B1
and C$
are all variables, and though it would not make sense P
may be a variable also.
Does anyone know what the ENTER
keyword is and what these parameters refer to?
Thanks in advance.
The ENTER statement is extraordinarily obscure; it does not appear in either the first or third editions of David Lien’s BASIC Handbooks, for example.
By searching on “ENTER #P” I was able to find one BASIC variant that does include it: HP 2000/Access BASIC. This particular manual is dated September 1975, so it fits loosely with the date of the program you’re looking at.
In HP 2000/Access BASIC (pages 2-15 and 11-33 of the manual), the ENTER statement is a variation of INPUT, one that provides no prompt and also stores more information about how and where the input was provided. The significance of the pound sign (#) is that it assigns the user port number to that variable. In your case, the “user port number” is assigned to the variable P
.
In your example:
P
will be assigned the user port number.B2
is the number of seconds the user has to respond. If the user does not respond, the value returned will be -256; -257 and -258 are error conditions.B1
is the number of seconds the user actually took to respond.C$
is the variable which will be assigned the value the user enters, if they enter it in the appropriate time.The “user port number” does not appear to be defined in the manual; however, contextually it appears to be the port on which the user is logged into the system. It can be a number “in the range from 0 to 31.” The port number appears to be mainly, or only, used for logging purposes. I don’t see anywhere in the manual where the port number can be targeted by the BASIC program.
From the manual:
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)
Fortunately P
is the variable used for the port number in this example as it is in yours; otherwise, the search would not have found this manual.