qb45advr.hlp (Topic list)
INPUT$ Function Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
INPUT$ Function Programming Example
 
This example prints a file on the screen using INPUT$ to read
one character at a time, then converting the character as
necessary and displaying it.
 
  Tip: 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.
CONST HTAB = 9, LFEED = 10
 
CLS    ' Clear screen
INPUT "Display which file"; Filename$
OPEN Filename$ FOR INPUT AS #1
CLS
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(R) 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);
    END IF
 
LOOP
END