What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Plug-Ins » See How Long You've Chatted To Contacts Each Month

Pages: (5): « First « 1 2 3 4 [ 5 ] Last »
See How Long You've Chatted To Contacts Each Month
Author: Message:
Dempsey
Scripting Contest Winner
*****

Avatar
http://AdamDempsey.net

Posts: 2395
Reputation: 53
38 / Male / Flag
Joined: Jul 2003
RE: See How Long You've Chatted To Contacts Each Month
Cookie - you should be a software tester for a living :p   
when i release the new screenshot sender you can use your amazing testing skills on that too if you want :D   ( if you have time of course)
SoundPacks   -   Scripts   -   Skins

that's not a bug, thats an unexpected feature
02-10-2005 07:48 PM
Profile E-Mail PM Web Find Quote Report
jasonallen
Full Member
***

Avatar
www.jason-allen.co.uk

Posts: 127
Reputation: 2
36 / Male / –
Joined: Jul 2003
O.P. RE: See How Long You've Chatted To Contacts Each Month
Thanks Cookie for ur info !

I really didn't think about continuing this piece of software. I stopped for a while, and now I'm lost in the code.

I'll go thru it now and explain how it is worked out.

The program reads down each of the lines of the text file until it finds the .-------. bit.
It goes down to the next line:

code:
SessionStartDate = Mid(TxtLine.ReadLine, 17, 20)

This reads the session start date.

code:
SessionStartDates(I) = SessionStartDate

and plugs it into an array.

It keeps reading down, and skips the next .----. because thats the bottom of the box. It repeats this until the end of the file, and then closes it.

The same file is then reopened to start at the start of the file again. There is no way I know of to go back easily in a text file. This time we skip the first .---. and move the next one.

code:
SessionStartTimeStr = Mid(t, 2, 8)

This reads the 8 chars of the time after the [.

Again, this is a repeated process to get all the session start times.

Now, how does the end time get found?....

Back later...

Windows XP Professional
Windows Live Messenger 14.0.8050.1202
Messenger Plus! Live 4.79.0.342
02-10-2005 08:00 PM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: See How Long You've Chatted To Contacts Each Month
quote:
Originally posted by j.g.allen
The program reads down each of the lines of the text file until it finds the .-------. bit. It goes down to the next line
(Y)

quote:
Originally posted by j.g.allen
This reads the session start date.
and plugs it into an array.
But why do you need this? The date is actually of no use when calculating the total time of chat in that log...

quote:
Originally posted by j.g.allen
There is no way I know of to go back easily in a text file.
consult your helpfiles (or the microsoft msdn library). To move the filepointer (in any type of file) use the statement "seek" (also works as a function).

quote:
Seek Statement: Sets the position for the next read/write operation within a file opened using the Open statement.

Syntax: Seek [#]filenumber, position

The Seek statement syntax has these parts:

filenumber Required. Any valid file number.
position Required. Number in the range 1 – 2,147,483,647, inclusive, that indicates where the next read/write operation should occur.

Remarks:

Record numbers specified in Get and Put statements override file positioning performed by Seek.

Performing a file-write operation after a Seek operation beyond the end of a file extends the file. If you attempt a Seek operation to a negative or zero position, an error occurs. (in VB the file starts at position 1 not 0)

Example:

Dim sTextLine as String

Open "TESTFILE" For Input As #1
  MsgBox "Size of file:" & LOF(1)
  Do While Not EOF(1)
    Line Input #1, sTextLine
    Debug.Print sTextLine
  Loop
  'Go back to the beginning
  Seek #1, 1
  Do While Not EOF(1)
    Line Input #1, sTextLine
    Debug.Print sTextLine
  Loop
Close #1

quote:
Originally posted by j.g.allen
This reads the 8 chars of the time after the [.
Not realy, it gets a substring from t starting at position 2 and (now the important part) reads the next 8 characters if they exist. This means if you have a line like in my testlog (the last line of the file) it will not return a string of 8 characters in length.

quote:
Originally posted by j.g.allen
1) The program reads down each of the lines of the text file until it finds the .-------. bit.
2) It goes down to the next line: SessionStartDates(I) = Mid(TxtLine.ReadLine, 17, 20)
3) It keeps reading down, and skips the next .----. because thats the bottom of the box.
4) It repeats steps 1-3 until the end of the file, and then closes it.
5) The same file is then reopened to start at the start of the file again.
6) This time we skip the first .---. and move the next one: SessionStartTimeStr = Mid(t, 2, 8)
7) Again, this (step 6) is a repeated process to get all the session start times.
You're making it way to complicated though ;)
1) (Y) that's a very good start. This makes sure that garbage in front of the file is skipped...
2) Date should be ignored, it is of no use for this program...
3) Here you already complicate things ;) This isn't needed... I'll explain later with an example...
4) Why not doing what you're doing in step 6 (reading the times) in here? There is no need to process the whole file, close it, reopen it and start again with actually the same process.
5) Thus, like said in step 4, read the times directly from the first time.
6) Again complicating things...




This pseudo-code is all you need to read those logs in one go and calculating the total chattime. It will skip over garbage automatically (because the only two acceptable lines are the ones with ".-----." and the ones with "[??:??:??]" (because that is all you need).

code:
GarbageSkipped = False
StartCounting = False
TotalTime = 00:00:00
StartTime = 00:00:00

Open "TESTLOG" For Input As #1
    While Not EOF(1)
        Line Input #1, sTextLine
        If sTextLine = ".-----." Then
            GarbageSkipped = True
            StartCounting = True
        ElseIf (sTextLine = "[??:??:??]") And (GarbageSkipped = True) Then
            FoundTime = GetTheTimeFrom(sTextLine)
            If StartCounting = True Then
                StartCounting = False
            Else
                TotalTime = TotalTime + FoundTime - StartTime
                If FoundTime < StartTime Then TotalTime = TotalTime + 24
            End If
        End If
        StartTime = FoundTime
    Wend
Close #1

Print "Total time chatted: " & TotalTime

I also attached a very commented VB source code which works with all the chatlogs (24h timeformat of course and in the form of "[??:??:??]", and the logs need to be saved as ASCII (thus unicode logs will not be read))

The source opens and correctly calculates my previous posted testlog file.

(note that the code can also be optimized a lot and made much more efficient though)

rest is up to you ;)

.zip File Attachment: calctest.zip (8.56 KB)
This file has been downloaded 265 time(s).

This post was edited on 02-11-2005 at 12:55 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
02-10-2005 10:59 PM
Profile PM Find Quote Report
atmlord
New Member
*


Posts: 5
Joined: Apr 2005
RE: See How Long You've Chatted To Contacts Each Month
bump.

How do i open and use that file? thanks
01-30-2006 01:10 AM
Profile E-Mail PM Find Quote Report
dennis
Junior Member
**

Avatar
RIGHT IN THE NUTS

Posts: 97
Reputation: -1
Joined: Jul 2005
RE: See How Long You've Chatted To Contacts Each Month
i like it bravo...
01-30-2006 04:40 AM
Profile E-Mail PM Find Quote Report
Menthix
forum admin
*******

Avatar

Posts: 5537
Reputation: 102
40 / Male / Flag
Joined: Mar 2002
RE: See How Long You've Chatted To Contacts Each Month
j.g.allen: Your download links are down.

quote:
Originally posted by dennis
How do i open and use that file?
I assume you mean the file Cookie posted? That is a Visual Basic source file. You will need a Visual Basic complier and some coding knowledge for that.
Finish the problem
Menthix.net | Contact Me
01-30-2006 10:45 AM
Profile E-Mail PM Web Find Quote Report
Pages: (5): « First « 1 2 3 4 [ 5 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On