qb45advr.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.
LINE INPUT # Statement Programming Example
  QuickSCREEN      Details     Example      Contents      Index
──────────────────────────────────────────────────────────────────────────────
LINE INPUT # Statement Programming Example
 
This example uses LINE INPUT # to echo data input to a file:
 
'*** Programming example for LINE INPUT # statement***
OPEN "LIST" FOR OUTPUT AS #1
PRINT "CUSTOMER INFORMATION:"
' Get customer information.
DO
    PRINT
    INPUT "   LAST NAME:  ", LName$
    INPUT "   FIRST NAME: ", FrName$
    INPUT "   AGE:        ", Age$
    INPUT "   SEX:        ", Sex$
    Sex$=UCASE$(Sex$)
    WRITE #1, LName$, FrName$, Age$, Sex$
    INPUT "Add another"; R$
LOOP WHILE UCASE$(R$)="Y"
CLOSE #1
 
' Echo the file back.
OPEN "LIST" FOR INPUT AS #1
CLS
PRINT "Records in file:" : PRINT
DO WHILE NOT EOF(1)
    LINE INPUT #1, REC$ 'Read records from file with
    PRINT REC$          'LINE INPUT #. Print the
                        'records on the screen.
LOOP
 
Sample Output
 
CUSTOMER INFORMATION:
 
 
   LAST NAME:  Saintsbury
   FIRST NAME: Aloysius
   AGE:        35
   SEX:        m
Add another? y
 
   LAST NAME:  Frangio
   FIRST NAME: Louisa
   AGE:        27
   SEX:        f
Add another? n
 
Records in file:
 
"Saintsbury","Aloysius","35","M"
"Frangio","Louisa","27","F"