Trace Window Usage

This forum is dedicated to everything about MemBrain Scripting. All Questions or other contributions with respect to scripting should be placed here.
Especially, if you have an interesting script that you might want to share with other MemBrain users, please post it within a new topic in this forum. Try to choose a title for your topic that allows other users to quickly identify the basic purpose of your script.
Post Reply
MrCreosote
Posts: 55
Joined: Wed 21. Jul 2010, 18:43

Trace Window Usage

Post by MrCreosote » Mon 25. Oct 2010, 18:54

Is there any way to increase the number of lines displayed in the Trace Window?

I like to write programs that have elaborate log files that log every phase of the algorithm during execution. The trace window works perfectly for that.

Is there any way that the contents of the trace window could be dumped into a text file?

Thanks
Tom

User avatar
Admin
Site Admin
Posts: 438
Joined: Sun 16. Nov 2008, 18:21

Re: Trace Window Usage

Post by Admin » Mon 25. Oct 2010, 19:35

MrCreosote wrote:Is there any way that the contents of the trace window could be dumped into a text file?
Not directly.

But how about this: Open a txt file on your own using the normal file class of the scripting language.

Then write a function called 'MyTrace(const string &in message) ' that does both, call the function 'Trace' to put the contents in the trace window and that writes the string to the file.

Could look something like this (the following lines are not compiled code, they are just written from the top of my head):

Code: Select all


file logFile; // The log file object of the script

void MyTrace(const string&in message)
{
    Trace(message + "\r\n"); // Write content to the trace window
    
    // Now write the same message line to the log file. 'logFile' must be an object of class 'file' that has been opened in txt mode.
    if (!logFile.Write(message + "\r\n"))
    {
        Trace("Can't write to log file!\r\n");
    }
}


void main()
{
    if (!logFile.Open("SomeFile.txt", FILE_MODE_CREATE | FILE_SHARE_DENY_NONE))
    {
        MessageBox("Unable to open log file");
    }

    MyTrace("This is an example text that will end up both in the Trace Window and in the log file");
}

Thomas Jetter

Post Reply