bas7ex.hlp (Topic list)
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 Programming 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.DOC text file.
 
'ASCII codes for tab, and line feed.
DEFINT A-Z
CONST HTAB = 9, LFEED = 10
 
CLS    'Clear 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