' COINS.BAS
' This program uses the WRITE# statement to send coin-collection
'   information to a sequential file in fields.

OPEN "COINS.TXT" FOR OUTPUT AS #1  ' open file in current drive/dir

CLS

PRINT "This program stores coin-collection information on disk in a"
PRINT "file named COINS.TXT.  Enter coin data and type END to quit."
PRINT

DO WHILE (country$ <> "END")       ' until the user types END...

' get coin-collection info from user and write it to the open file

    INPUT "What country is the coin from?  ", country$
    IF (country$ <> "END") THEN    ' if country$ is END don't write
        INPUT "What is the value of the coin?  ", value$
        INPUT "What is the name of the coin?   ", coinName$
        INPUT "What year was the coin minted?  ", year%

        WRITE #1, country$, value$, coinName$, year%  ' send fields
    END IF
    PRINT                          ' print blank lines between coins

LOOP

CLOSE #1                           ' close the file

PRINT "Information has been successfully written to COINS.TXT"

