Reset Statement

See AlsoH8U56C              Example3S7W9SX>Low

Closes all disk files.

Syntax

Reset

Remarks

The Reset statement closes all open disk files and writes the contents of all MS-DOS file buffers to disk.  .


See Also

Close StatementPMJS3T

End StatementLANEND


Reset Statement Example

The example uses Reset to close open files and flush the contents of MS-DOS file buffers out to disk.  To try this example, paste the code into the Declarations section of a form.  Then press F5 and click the form.

 

Sub Form_Click ()

   Dim ClientName As String * 20         ' Declare variables.

   Dim Indx, Max, Msg, NL

   NL = Chr(10)                          ' Define newline.

   ' Make a sample random-access file using the Put statement.

   Msg = "Enter a name, using whatever form you like." & NL & NL

   Msg = Msg & "Press 'Enter' with no name to conclude entry."

   Open "TESTFILE" For Random As #1 Len = Len(ClientName)

   ClientName = InputBox(Msg)            ' Get user input.

   Do While ClientName <> String(20, " ")

      Put #1, , ClientName               ' Write to file.

      ClientName = InputBox(Msg)         ' Get user input.

   Loop

   Reset                                 ' Flush buffers, close file.

   Open "TESTFILE" For Random As #1 Len = Len(ClientName)

   ' Read the sample random-access file using the Get statement.

   Max = Loc(1)

   If Max = 0 Then                       ' Check if records exist.

      Msg = "Your file contains no names." & NL

   Else

      Msg = "Your file contains the following names:" & NL & NL

   End If

   For Indx = 1 To Max

      Get #1, Indx, ClientName           ' Read from file.

      Msg = Msg & ClientName & NL

   Next Indx

   Close #1                              ' Close file.

   Msg = Msg & NL & "Choose OK to remove the created test file."

   MsgBox Msg                            ' Display message.

   Kill "TESTFILE"                       ' Remove file from disk.

End Sub