Examples: Open statement

' In this example, LotusScript reads the contents of a
' comma-delimited ASCII file (c:\123w\work\thenames.txt)
' into an array of RecType. RecType is a user-defined
' data type.
' c:\123w\work\thenames.txt consists of the following:
' "Maria Jones", 12345
' "Roman Minsky", 23456
' "Joe Smith", 34567
' "Sal Piccio", 91234

Type RecType
   empId As Double
   employee As String 
End Type       
Dim arrayOfRecs() As RecType
' A dynamic array that will get sized to
' the number of lines in c:\123w\work\thenames.txt
Dim txt As String
Dim fileNum As Integer
Dim counter As Integer
Dim countRec As Integer
' Get an unused file number so LotusScript can open a file.
fileNum% = FreeFile()
counter% = 0
Open "c:\123w\work\thenames.txt" For Input As fileNum%
Do While Not EOF(fileNum%)
   ' Read each line of the file.
   Line Input #fileNum%, txt$
   ' Increment the line count.
   counter% = counter% + 1
Loop
' Return the file pointer to the beginning of the file.
Seek fileNum%, 1
' The file has counter number of lines in it, so
' arrayOfRecs() is defined with that number of elements.
ReDim arrayOfRecs(1 To counter%)
' Read the contents of the file into arrayOfRecs.
For countRec% = 1 To counter%
   Input #fileNum%, arrayOfRecs(countRec%).employee$, _
      arrayOfRecs(countRec%).empId#
Next
Close fileNum%
Print arrayOfRecs(2).employee$ & " " arrayOfRecs(2).empId#
' Output:
' Roman Minsky 23456

'Examples using MIMEcharsetname
Open "EBCDIC.TXT" for output  access write _
   as ff CHARSET="ebcdic-us"

Open "UNICODE.TXT" for output access write _
   as ff CHARSET="utf-16"

Open "ASCII.TXT" for output Access write _
   as ff CHARSET="ascii"