Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
INPUT$ Function Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
' This example uses the INPUT$ function to read one character at a time from
' a file. The input character is converted to standard printable ASCII, if
' necessary, and displayed on the screen.
' Note: You must supply a text file when you run this example. Use a text
' file you have already created, create a file with a text editor, or
' specify the README.TXT text file.
' To try this example:
' 1. Choose New Project from the File menu
' 2. Copy the code example below to the code window
' 3. Press F5 to run the example
DEFINT A-Z
CONST HTAB = 9, LFEED = 10 ' ASCII codes for tab, and linefeed
CLS ' Clear the screen
INPUT "Display which file"; Filename$
OPEN Filename$ FOR INPUT AS #1
DO WHILE NOT EOF(1) ' Input a single character from the file
S$ = INPUT$(1, #1) ' Convert the character to an integer and
' turn off the high bit so WordStar files
' can be displayed
C = ASC(S$) AND &H7F ' Is it a printable character?
IF (C >= 32 AND C <= 126) OR C = HTAB OR C = LFEED THEN PRINT CHR$(C);
LOOP
END