%Library.FileCharacterStream
Class %Library.FileCharacterStream Extends (%CharacterStream, %FileStreamAdaptor) [ Deprecated, Inheritance = right, MemberSuper = (%Compiler.Type.FileStream, %Compiler.Type.StreamLegacy), StorageStrategy = Custom, System = 2 ]
Stream class that stores character data in external files. This class is deprecated in favor of %Stream.FileCharacter. For example the following code opens a file character stream, points it at a particular file on the filesystem and then reads it in line by line: Set stream=##class(%FileCharacterStream).%New() Set stream.Filename="c:\myfile.txt" While 'stream.AtEnd { Set line=stream.ReadLine() ; Process the line here }
The difference between file character stream and file binary streams is that the character stream understands that it is writing character data and this may be subject to characterset translation. For example you may wish to utf-8 encode character data being written to the file, but with a binary file stream it is just a series of binary data and so this is always read/written exactly as it is without and translation. Also the file is written in 'S' mode so for example writing cr/lf on a unix system will just append lf as this is the unix line terminator.
Parameters
OPENREAD
Parameter OPENREAD = "RU";
OPENWRITE
Parameter OPENWRITE = "WSN";
OPENAPPEND
Parameter OPENAPPEND = "AWS";
OPENREADTERM
Parameter OPENREADTERM = "RS";
Properties
StreamFormatWrite
Property StreamFormatWrite As %Boolean [ InitialExpression = 1, Transient ];
The StreamFormatWrite property controls whether file output is in stream or undefined format. If StreamFormatWrite is 1 (true), the default, the file is written in S (stream) format. If StreamFormatWrite is 0 (false), the file is written in U (Undefined) format. For Unix file output, S format converts crlf to lf which can be a problem for MIME output such as email. The user can now set messagepart.TextData.StreamFormatWrite=0 to keep crlf in text message parts of the mail message.
TranslateTable
Property TranslateTable As %String [ InitialExpression = "0", Transient ];
The translation table to be used when reading or writing the file.
See Translation Tables. Initial value of 0 indicates that the table has not yet been set.
If translation table is set after the file has been opened then switch the table used for the file. If the translation table is set to "", then the "RAW" table is used.
BOM
Property BOM As %String [ Transient ];
BOM characters that appear at start of file to signify which encoding it is using
Methods
%Oid
Method %Oid() As %ObjectIdentity
Returns the OID of this object.
TranslateTableSet
Method TranslateTableSet(table As %String) As %Status
If translation table is set after the file has been opened then switch the table used for the file. If the translation table is set to "", then the "RAW" table is used.
IsFileUnicode
Method IsFileUnicode() As %Boolean
Returns true if the file is Unicode. This method may only be called after data has been read from the file stream.
GetReadOpenParameter
Method GetReadOpenParameter(filename As %String, mode As %Integer, ByRef pos As %Integer) As %String [ Private ]
GetWriteOpenParameter
Method GetWriteOpenParameter(filename As %String, mode As %Integer) As %String [ Private ]
SizeGet
Method SizeGet() As %Integer
Return the current size of the data stream. Note this is complicated by having to worry about the translate table used to write the file.