Equilla TextFileReader

The TextFileReader object is an Equilla COM-based Extension that is included as part of the standard Tradesignal installation. The TextFileReader object presents an Application Programmers Interface (API) for reading text files from the local workstation or network.

The full Visual Studio project and source code for the TextFileReader object are included in the Tradesignal install directory under the Samples folder. The sample project demonstrates how to create an Equilla COM-based extension using unmanaged C++.

The TextFileReader will try to determine the encoding of the text file (ASCII, UTF-8, UTF-16, etc.).

Usage Example

This example indicator will read a text file (identified by filename input) and output the file line by line to the Tradesignal output window with line numbering:
Input:
    Filename( "C:\MyTextFile.txt" );
// Replace this with a path to an existing text file.

Object:
    textFileReader( "EquillaExt.TextFileReader" );


Variables:
    currentLine( "" ), lineNumber( 0 );

    
If CurrentBar = 1 Then Begin
    If textFileReader.OpenTextFile( Filename ) Then Begin
        While textFileReader.IsEOF() = False Begin
            currentLine = textFileReader.ReadLine();
            lineNumber = lineNumber + 1;
            
            // Do something with the line, e.g.:
            Print( lineNumber, currentLine );
        End;
        
        textFileReader.CloseFile();
    End;
End;
Please note: Before you can compile the above sample, you may need to enable Equilla extensions using the option under File > Tradesignal Options > Equilla.

TextFileReader Interface

[ProgId("EquillaExt.TextFileReader")]
interface ITextFileReader
{
    // Tries to open a text file with the specified name, returns true if file is opened
    bool OpenTextFile(string Filename);

    // Ensures any previously opened file is closed, returns true if file is closed
    bool CloseFile();

    // Tries to read a line of text from the currently open text file. The resulting text
    // does not contain line end markers.
    string ReadLine();

    // Tries to read a specific number of characters from the currently open file. The resulting
    // text may contain line end markers.
    string ReadChars(int NumberOfChars);

    // Returns the creation date and time of the currently open text file.
    DateTime GetCreateDate();

    // Returns the last write date and time of the currently open text file.
    DateTime GetModifyDate();

    // Returns the length in bytes of the currently open text file.
    int GetFileLength();

    // Returns the current read position for the currently open text file.
    int GetFilePosition();

    // Moves the read position for the currently open text file to the specified value,
    // returns true if successful
    bool SetFilePosition(int Position);

    // Returns true if the read position for the currently open text file has reached
    // the end of the file.
    bool IsEOF();

    // Returns if the text file is currently open.
    bool IsOpen();

    // Returns the name and path of the currently open text file.
    string GetFilename();
}