function Main as String
' Counts the number of lines in the text file.

' THE EXAMPLE ILLUSTRATES THE USE OF:
'   ParamStr
'   ParamCount
'   open
'   eof
'   close

  dim LinesCount as Integer
  dim Done as Boolean
  dim FileName as String
  
  if ParamCount <> 1 then 
    Main = "I want a filename in the first parameter"
    Exit Function
  end if
  
  FileName = ParamStr(1)
  LinesCount = 0
  open FileName access read as #1
  eof #1, Done
  while not Done
    read #1
    LinesCount = LinesCount + 1
    eof #1, Done
  end while
  close #1
  
  Main = "File '" + FileName + "' contains "+ Str(LinesCount) + " lines"
end function