ReadTextFile
(Requires Analytica Enterprise, Optimizer, or Power Player)
ReadTextFile(filename, showDialog, title)
Returns the contents a text file «filename» as a text value. By default, it shows a file browser dialog if it can't find a file with that name.
Set optional parameter, «showDialog» to True
(1) to show the file browser dialog, using «filename» as default, even if the file exists. Set «showDialog» to False
(0) to never show it. In the latter case, it will show an error message if it can't find the file.
You can specify the caption for the file selector dialog titlebar in the optional «title» parameter.
ADE never shows the file browser dialog, no matter what the parameter values.
Treating End-of-line
There are three common standards in text-files to identify newlines:
- Windows files usually use the two-character sequence CRLF -- Chr(10) Chr(13)
- Unix files use a single LF character -- Chr(10)
- Macintosh OS files use a single CR character -- Chr(13)
Occasional Windows-based programs use one of the other standards.
ReadTextFile insulates you from worrying about which standard is used by converting each to the Unix standard, a single LF -- Chr(10).
If a file contains inconsistent line breaks -- e.g. including more than one examples of LF, CRLF, and CR -- it converts LF and CRLF to a single LF, and leaves CR -- Chr(13) -- as is.
History
- The «title» parameter was introduced in Analytica 4.6.
Enable comment auto-refresher