ReadTextFile


(Requires Analytica Enterprise, Optimizer, or Power Player)

ReadTextFile(filename, showDialog, title)

Returns the contents a text file «filename» as a text value. «filename» may be the name of a file in the Current Data Directory or a path relative to the Current Data Directory , or an absolute pathname.

If it can't find a file with that name, by default, it shows a file browser dialog to let the user select another file. 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 that case, if it can't find the file, it shows an error message.

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

See Also

Comments


You are not allowed to post comments.