Input

Syntax

Input #FileNumber, Variable1[$] [Variable2[$]] [Variable3[$]] [, ¼]

Input [Prompt$,] Variable1[$] [Variable2[$]] [Variable3[$]] [, ¼]

Remarks

Retrieves string or numeric values from a sequential file, typically containing data added with the Print statement, and assigns the values to variables. FileNumber is the number specified in the Open instruction that opened the file for input. For more information about sequential files, see Chapter 9, "More WordBasic Techniques," in Part 1, "Learning WordBasic."

Input is similar to Read in that it retrieves comma-delimited values from sequential files, but unlike Read, it does not remove quotation marks from string values. Input can accept strings with as many as 65,280 characters. Longer strings are truncated. For more information, see Read.

If FileNumber is omitted, the user is prompted with a question mark (?) in the status bar to type one or more values, separated by commas. The user presses ENTER to end keyboard input. If Prompt$ is specified, the question mark follows the string.

Examples

This Windows example opens for input a list of files to save in rich-text format (RTF). Assume that FILES.TXT is a text file in which each paragraph contains two string values: the filename to open and the filename to save. The instructions open each file in turn and save it in RTF. On the Macintosh, substitute folder names such as HD:WORD DOCS: and HD:RTF DOCS:.


Open "C:\DOCS\FILES.TXT" For Input As #1
While Not Eof(#1)
    Input #1, docname$, rtfname$
    FileOpen "C:\DOCS\" + docname$
    FileSaveAs .Name =  "C:\RTF\" + rtfname$, .Format = 6
    FileClose 2
Wend
Close #1

The following example displays the prompt "RTF filename?" in the status bar and defines the variable rtfname$ with the text the user types:


Input "RTF filename", rtfname$

See Also

Close, Eof(), Input$(), InputBox$(), Line Input, Lof(), Open, Read, Print, Seek, Write