File operations

<< Click to Display Table of Contents >>

File operations

In SoftMaker Basic, you have access to all the usual file operations. Below is a small example. Further information on the individual statements can be found in the chapter Statements and functions from A to Z.

Example:

Sub FileIO_Example

 Dim i, Msg

 Call Make3Files()

 Msg = "Three test files have been created. "

 Msg = Msg & "Press OK to delete them."

 MsgBox Msg

 For i = 1 To 3

         Kill "TEST" & i                       ' Delete files

 Next i

End Sub

Sub Make3Files

 Dim i, FNum, Fname

 For i = 1 To 3

         FNum = FreeFile                       ' Get the next free file number

         FName = "TEST" & FNum

         Open FName For Output As FNum         ' Open file

         Print #i, "This is test #" & i       ' Write to file

         Print #i, "Here comes another "; "line"; i

 Next i

 Close                                      ' Close all files

End Sub