Allows the input of one or more variables, with or without the prompt.
Input ["Text",] x [,y,...] Input ["Text";] x [,y,...]
Line Input ["Text",] a$ [,b$,...] Line Input ["Text";] a$ [,b$,...]
Form Input n, var Form Input n As var
Text: any text as prompt
a$, b$: string variable
n : integer
var: variant or string
x, y: any variable type
All the above commands always start from the last cursor position. To define the location where the input should take place, the cursor can be positioned using Print At followed by a semicolon, Locate, VTab or HTab.
Both Line Input and Input contain an optional prompt which is separated from the following variables by a comma or a semicolon and both can receive multiple variables, strings only for Line Input or any variable type for Input. It is advised that Line Input is used for inputting strings as it's entries can contain commas, whereas a string entered with Input can not. The maximum input length for strings is 10000 characters and special characters can be entered by typing numbers on the numeric key block while holding down the alternate key <Alt>.
If only one variable is requested, its input must be ended by pressing the <Return> or the <Enter> key. If Input contains a list of variables the entry of each individual variable is terminated by pressing the <Return> or the <Enter> key. Any corrections within the variable list are made by using the <Backspace>, <Delete> and <Insert> keys, as well as the cursor keys. Unfortunately, unlike in GFABASIC16, it is no longer possible to separate individual variables in the list with commas and confirm them all with one single press of the <Return> or the <Enter> key (see examples for a workaround).
Form Input differs in that it can only accept a single string (or variant) and that any value input is restricted to the number of letters specified by the n integer value.
OpenW 1
Local a$, a%, b$
Local Double x, y
HTab 10 : VTab 9
Print "First Name:"; : Form Input 20 As a$
HTab 10 : VTab 10
Line Input "Surname:", b$
Print AT(40, 20);
Input "Enter two numbers: ";x, y
Print a$`b$`x`y
Do : Sleep : Until Win_1 Is Nothing
In GFABASIC16, it was possible to input a list of variables in one input box by separating them with commas; sadly, this no longer works in GFABASIC32, although it is quite easy to replicate this action, as the following code shows:
Local a$, p As Int32, x As Double, y As Double
Input "Enter two values:";a$
p = InStr(a$, ",")
If p = 0 // No commas
x = Val(a$)
Input "...and the second value:";y
Else
x = Val(Left(a$, p - 1))
y = Val(Mid(a$, p + 1))
EndIf
Print x, y
Another possible workaround uses InputBox as shown below:
// Courtesy of Factor23
Local Int16 a, b
entree("a,b", *a, *b)
Proc entree(t$, ParamArray p())
Local h As Hash String, l$, i = LBound(p())
l$ = InputBox(t$)
Split h[] = l$, ","
For i = LBound(p()) To UBound(p())
DblPoke p(i) , Val(h[% i + 1])
Next i
Print t$; " : "; l$
End Proc
Input, Line Input and Form Input date from the days before forms and text boxes and are included for backwards compatibility. Better results can be achieved using either InputBox, OCX Richedit, Prompt and OCX TextBox controls.
LineInput and Input can both be used to retrieve data from files - see here
{Created by Sjouke Hamstra; Last updated: 30/03/2016 by James Gaite}