can anyone teach me how to do it correctly? :-\
i know the general concept of how to do it, and tried searching the forums for the answer but all the examples confused me. (which is surprisingly ez with all the stress i been having to handle lately) i need to know stuff like how to properly declare all the neccassary functions like GetTickCount n'such.
Aswell it would be nice to get example coding on how to use the functions. I'm planning on using bot uptime for an idle, but that doesnt really matter, all im asking for is the general coding for it.
help is greatly appreciated. :-\
And we are to understand you are coding in Ada?
I assumed it was java..
use System.getTime().
VB my bad :-[
I'll try to help you without giving you code. This makes you "smarter (tm)" and "more independent (tm)".
You want to know how long your bot has been connected. You'll need to do three things:
1) Store at what time your bot connected.
2) Determine what time it is "now."
3) Find how much greater "now" is than the time in step 1.
Visual Basic has several helpful functions that you can use. Play around with Now() and the DateDiff() function, which returns the difference between two DateTimes.
Good luck.
Quote from: K on May 11, 2003, 12:44 PM
Visual Basic has several helpful functions that you can use. Play around with Now() and the DateDiff() function, which returns the difference between two DateTimes.
i prefer gettickcount, as long as you're only trying to find the ammount of time difference,t here's no need for those. may be a good idea if you're just learning tho.
Except that with GetTickCount() you have milliseconds which you need to convert into a readable format; the DateTime will take care of that for you, which is why I recommended it.
Quote from: K on May 11, 2003, 12:44 PM
I'll try to help you without giving you code. This makes you "smarter (tm)" and "more independent (tm)".
You want to know how long your bot has been connected. You'll need to do three things:
1) Store at what time your bot connected.
2) Determine what time it is "now."
3) Find how much greater "now" is than the time in step 1.
ya i knew that already :P i coulda sworn i said i knew the concept of how its done.
and im more of a visual learner then someone who learns by doing. in other words i learn better by visually seeing the code then spending hours trying to figure it out. and i'd have to say im pretty independant. ive only known VB since last january (started programming with QB last november). my first project using VB is a chat bot and this is only the 2nd time ive required help. (for some reason i have a harder time working with the ez stuff then the hard stuff)
Quote from: OcTaViuS on May 11, 2003, 02:34 PMfor some reason i have a harder time working with the ez stuff then the hard stuff
I know that feeling ;)
All it takes to overcome that, though, is to try, try, and try harder. And if that fails, that you step back and take look at why you're trying too hard.
Private Sub Form_Load()
r = Now 'Set your first time to when it connects
End Sub
Private Sub Whatever()
g = Now 'Set your second time when you want to check date diff
Msgbox GetDiff(r,g)
End Sub
Private Function GetDiff(Date1 as Date, Date2 as Date)
GetDiff = DateDiff("h", Date1, Date2) ' "h" is an interval, check below for more settings
End Function
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
m Minute
s Second
Quote from: iago on May 11, 2003, 10:49 AM
I assumed it was java..
use System.getTime().
no.
Quote from: drivehappy on May 11, 2003, 06:19 PM
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
m Minute
s Second
umm, is "m" for Month or Minute? you listed it for both. im guessing its for month since it doesnt seem to work for me as minute. but if thats the case then wuts the one for minute?
Quote from: OcTaViuS on May 22, 2003, 08:35 PM
Quote from: drivehappy on May 11, 2003, 06:19 PM
Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week of year
h Hour
m Minute
s Second
umm, is "m" for Month or Minute? you listed it for both. im guessing its for month since it doesnt seem to work for me as minute. but if thats the case then wuts the one for minute?
yeah, for a while my bot was displaying the month instead of the minute in the timestamp >.<
minute is n
Case "sysuptime"
Send "/me Bot Uptime - " & vbTab & vbTab & vbTab & ConvertTime(GetTickCount - RunningTime)
Send "/me System Uptime - " & ConvertTime(GetTickCount()) & "
that would work on VB for uptime on bot and cpu
ConvertTime is not a standard VB function; it would be nice if you provided the code to it if you're going to use it in an example.
im surprized that he created his own function, did he?
Public Function UpTime() As String
Dim ticks As Long
ticks = GetTickCount
UpTime = "Computer on for " & GetTime(ticks) & _
", running for " & GetTime(ticks - StartTime) & _
", logged on for " & GetTime(ticks - LogTime)
End Function
Public Function Zero(str As String, Count As Long, Optional Char As Byte = "0") As String
Zero = String(Count - Len(str), CStr(Char)) & str
End Function
Public Function GetTime(ByVal ticks As Long, Optional ShowDecimals As Boolean = False) As String
Dim TS As Long, TM As Long, TH As Long, TD As Long, TW As Long
TS = ticks \ 1000: ticks = ticks - TS * 1000
TM = TS \ 60: TS = TS - TM * 60
TH = TM \ 60: TM = TM - TH * 60
TD = TH \ 24: TH = TH - TD * 24
TW = TD \ 7: TD = TD - TW * 7
GetTime = Zero(CStr(TS), 2) & IIf(ShowDecimals, "." & Zero(CStr(ticks), 3), "") & "s"
If TM + TH + TD + TW > 0 Then GetTime = Zero(CStr(TM), 2) & "m " & GetTime
If TH + TD + TW > 0 Then GetTime = Zero(CStr(TH), 2) & "h " & GetTime
If TD + TW > 0 Then GetTime = CStr(TD) & "d " & GetTime
If TW > 0 Then GetTime = CStr(TW) & "w " & GetTime
End Function
?UpTime
Computer on for 1w 2d 23h 03m 30s, running for 22h 04m 08s, logged on for 22h 04m 07s
camel u r god :o. not only did u successfully answer my bot uptime question without making me guess on how to fix the code, but u also gave me the code for cpu uptime and connection uptime, the two uptimes i was about to try and figure out during the weekend.
gj & ty 8)
Quote from: OcTaViuS on May 23, 2003, 07:42 PM
camel u r god :o. not only did u successfully answer my bot uptime question without making me guess on how to fix the code, but u also gave me the code for cpu uptime and connection uptime, the two uptimes i was about to try and figure out during the weekend.
gj & ty 8)
However, the code as provided won't properly render typical service uptimes. You need a higher resolution solution.
Quote from: Kp on May 23, 2003, 11:44 PM
However, the code as provided won't properly render typical service uptimes. You need a higher resolution solution.
way to spoil the mood.
It's really not that hard. I'm sure that there is an example on pscode.com
mr. raza, camels method works perfectly...
I was regarding to the High Resolution solution kp was talking about.
Quote from: MrRaza on May 25, 2003, 04:25 PM
I was regarding to the High Resolution solution kp was talking about.
use quotes, fooligan
betcha cant say "Resolution Solution" 10x fast :o good one KP ::)