' This subroutine writes the database (arrrays nm and phone) to the disk SUB outfile DIM ans, i AS INTEGER ' if the database to be saved to disk is empty, doublecheck with the user IF n = 0 THEN PRINT "Database is empty." INPUT "Are you sure (1 for yes, 0 for no)? ", ans IF ans <> 1 THEN PRINT "Save operation cancelled" EXIT SUB END IF END IF ' open the file to write OPEN filename FOR OUTPUT AS #1 ' write the data to the file in a way that makes it possible to read them back ' with subroutine infile PRINT #1, n FOR i = 1 TO n PRINT #1, nm(i) PRINT #1, phone(i) NEXT ' close the file CLOSE #1 ' mark the database as unchanged (saved) changed = 0 PRINT "Database saved to file" END SUB