Open Statement[Runtime]/text/sbasic/shared/03020103.xhpSun Microsystems, Inc.converted from old format - fpeOpen statementOpen Statement[Runtime]Opens a data channel.Syntax:Open FileName As String [For Mode] [Access IOMode] [Protected] As [#]FileNumber As Integer [Len = DatasetLength]UFI: #i37502#Parameters:FileName: Name and path of the file that you wan to open. If you try to read a file that does not exist (Access = Read), an error message appears. If you try to write to a file that does not exist (Access = Write), a new file is created.Mode: Keyword that specifies the file mode. Valid values: Append (append to sequential file), Binary (data can be accessed by bytes using Get and Put), Input (opens data channel for reading), Output (opens data channel for writing), and Random (edits relative files).IOMode: Keyword that defines the access type. Valid values: Read (read-only), Write (write-only), Read Write (both).Protected: Keyword that defines the security status of a file after opening. Valid values: Shared (file may be opened by other applications), Lock Read (file is protected against reading), Lock Write (file is protected against writing), Lock Read Write (denies file access).FileNumber: Any integer expression from 0 to 511 to indicate the number of a free data channel. You can then pass commands through the data channel to access the file. The file number must be determined by the FreeFile function immediately before the Open statement.DatasetLength: For random access files, set the length of the records.UFI: #61736You can only modify the contents of a file that was opened with the Open statement. If you try to open a file that is already open, an error message appears.Example:Sub ExampleWorkWithAFileDim iNumber As IntegerDim sLine As StringDim aFile As StringDim sMsg as StringaFile = "c:\data.txt"iNumber = FreefileOpen aFile For Output As #iNumberPrint #iNumber, "This is a line of text"Print #iNumber, "This is another line of text"Close #iNumberiNumber = FreefileOpen aFile For Input As iNumberWhile not eof(iNumber)Line Input #iNumber, sLineIf sLine <>"" thensMsg = sMsg & sLine & chr(13)end ifwendClose #iNumberMsgbox sMsgEnd Sub