Delgine 3D Tools & Content DeleD Community Edition
Forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Meet & Greet chat-session on October 26, 20:00 GMT+1
Goto page Previous  1, 2
 
Post new topic   Reply to topic    DeleD Community Edition Forum Index -> News / Announcements
View previous topic :: View next topic  
Author Message
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Mon Oct 31, 2005 9:20 am    Post subject: Reply with quote

trucker2000 wrote:
That looks really good. Smile

http://www.3dcentral.net/DeleD/Greet1.html


**laughing at self**

No it doesn't. The forum cut half of it off. It's been mailed. I'm about to go injure myself in frustration now...

I wonder why it errors out and repeats the last line?

Code:
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>


using namespace std;

int main()
{

    fstream fLog;
    stringstream ss;

    fLog.open("log.txt",fstream::in);
    if (!fLog.is_open())
    {
        cout << "Error opening file!\nProgram aborting!";
        return EXIT_FAILURE;
    }

    ss << fLog.rdbuf();
    fLog.close();

    char    ca[1024]; memset(ca,0,sizeof(ca));

    string  sLine;
    int     nLine = 0;
    int     nPos;
    string  sHTML;

    sHTML += "<html>\n";
    sHTML += "<body margin=\"20\" bgcolor=\"#FFEBCD\"  TEXT=\"000000\">\n";

    while (!ss.eof())
    {
        ss.getline(ca,1024,'\n');
        if (strlen(ca) == 0) break;

        //cout << nLine << ":" << ca << endl;
        ++nLine;

        //replace any < brackets with [
        for (int i = 0; i < strlen(ca); ++i)
        {
            if (ca[i] == '<') ca[i] = '[';
            if (ca[i] == '>') ca[i] = ']';
        }

        //convert the line to html
        if (ca[0] == '[') sLine = "<b>";
        else sLine == "";
        sLine += ca;

        //unbold after the second ']'
        //and add coloured text
        nPos = sLine.rfind("]");
        if (nPos != string::npos)
        {
            sLine.insert(nPos+1,"</b> &nbsp;&nbsp;<font color=\"0000FF\">");
            sLine += "</font><br>";
        }
        else sLine += "<br>";

        sLine += "\n";

        sHTML += sLine;
    }

    fLog.close();

    sHTML += "\n</font></body>\n</html>";


    fstream fHTML;

    fHTML.open("Log.html",fstream::out| fstream::trunc);
    if (!fHTML.is_open())
    {
        cout << "Error opening file!\nProgram aborting!";
        return EXIT_FAILURE;
    }

    fHTML << sHTML.c_str();

    fHTML.close();

    cout << "\n\n *** Log converted. " << nLine << " lines. ***\n\n";

   return EXIT_SUCCESS;
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Wed Nov 02, 2005 7:19 am    Post subject: Reply with quote

*lol* I didn't format the log on purpose, because I thought it was part of IRC 'etiquette' to leave the logs at what they are: simple textfiles (i.e. don't force html formatting down people's troats when all they want is to download the text)... Perhaps I am just old and sad Very Happy

Thanks a lot for all the effort, guys. I'll put a formatted version of the log online in a minute.
Back to top
View user's profile Send private message Visit poster's website
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Wed Nov 02, 2005 7:22 am    Post subject: Reply with quote

MrFletcher: Your request has been noted. It's a good idea, thanks!
Back to top
View user's profile Send private message Visit poster's website
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Wed Nov 02, 2005 7:28 am    Post subject: Reply with quote

Vampyre: Haven't got a clue why the code above would error out, really Smile I always have to resort to hands-on debugging with C++.
Back to top
View user's profile Send private message Visit poster's website
Daaark
DeleD PRO user


Joined: 01 Sep 2004
Posts: 2696
Location: Ottawa, Canada

PostPosted: Wed Nov 02, 2005 7:48 am    Post subject: Reply with quote

Paul-Jan wrote:
Vampyre: Haven't got a clue why the code above would error out, really Smile I always have to resort to hands-on debugging with C++.
I officially do't care anymore. Just wanted to help out. Was in the mood to code, but not work on my projects, so I wrote that to help. It just repeats the last line in the log for some reason. *shrug*

I just found the txt file hard to read as it was black on white, and it didn't wrap at all.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Paul-Jan
Site Admin


Joined: 08 Aug 2004
Posts: 3066
Location: Lage Zwaluwe

PostPosted: Thu Nov 03, 2005 10:36 am    Post subject: Reply with quote

The effort is much appreciated! Smile

I just replaced the text-log with a formatted version. Should have done so yesterday, but I am just slow.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    DeleD Community Edition Forum Index -> News / Announcements All times are GMT
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum