ConInputLine command


See the notes on emulating the PB/CC INPUT and CON.INPUT statements at the end of this section.



ConInputLine Prompt$, StringVar$


Legacy Syntax:

LINE INPUT ["prompt",] StringVar$


Pseudo-object Syntax:

CON.LINE.INPUT ["prompt",] StringVar$


Reads a line of text, terminated by <Enter>, from the keyboard.


The prompt is displayed and the program waits for keyboard input. Keyboard input characters are accumulated until <Enter> is pressed, then the string of entered characters is returned in the string variable. This function always returns keyboard input; it is not subject to input redirection. Use a null prompt string if no prompt is required.


For compatibility with PB/CC, the only active editing key is Backspace. All other editing keys (cursor right and left, Del, etc.) are ignored. Echo is always to the currently active page, whether or not this is the currently visible page. All control keys except Ctrl+M (CR, Enter) and Ctrl+H (BS, backspace) are ignored, including Ctrl+C. Windows acts on Ctrl+Break to terminate the program.




In the PB/CC LINE INPUT statement, the prompt is optional and must be a literal string if given. For ConInputLine, it may be a literal string or a string expression but must always be present, even if null.


In the PB/CC LINE INPUT statement, StringVar$ can be a fixed-length or null-terminated string in addition to being a dynamic string. For ConInputLine, it can only be a dynamic string.


Conversion of the INPUT statement:


The PB/CC INPUT (or CON.INPUT) statement cannot be emulated with a simple externally programmed procedure because its parameters include variable names, notvalues. It is not a straightforward command, but a deeply embedded compiler statement (it is one of the oldest BASIC statements, dating back to Dartmouth BASIC in the 1960s).


INPUT ["prompt",] VariableList

 - or -

CON.INPUT ["prompt",] VariableList


VariableList is a comma-delimited sequence of one or more variables. If more than one variable is specified, the user is expected to enter the proper number of values on a single line, separated by commas. When the user presses the <Enter> key, data between commas is extracted, leading spaces are removed, and the result is assigned to each variable in succession. If not enough comma-delimited values are entered, remaining variables are set to zero (if numeric) or empty (if string).


This behavior can only be emulated using ConInputLine and a succession of following statements to parse the returned string. The parsing statements must be specifically programmed to match the VariableList requested. For example:


#IF %DEF(%PB_CC32)

  INPUT "Input day, month and year, separated by commas: ", Day&, Month$, Year&


  ConInputLine "Input day, month and year, separated by commas: ", InputString$

  Day& = VAL(PARSE$(InputString$, 1))

  Month$ = PARSE$(InputString$, 2)

  Year& = VAL(PARSE$(InputString$, 3))



Note that an INPUT statement with just one string variable is equal to an equivalent LINE INPUT statement, if we accept that the user is not going to spitefully insert a comma expecting everything after it to be ignored. For example:


#IF %DEF(%PB_CC32)

  INPUT "What is your name? ", UserName$


  ConInputLine "What is your name?", UserName$



CON.LINE.INPUT or CONSOLE.LINE.INPUT may be substituted for LINE INPUT and CON.INPUT or CONSOLE.INPUT may be substituted for INPUT in programs written for PB/CC6.