Questiong about useing intstr(number)
Author |
Message |
TokenHerbz
|
Posted: Sun Apr 23, 2006 10:09 pm Post subject: Questiong about useing intstr(number) |
|
|
Hey, i have a program which creates the current time the programs been up and running for. Basicly it works perfectly exept for when i send it across the net...
When i send "intstr(hr:min:sec)" it's as if the program dosn't work because it'll start out puting like, 00:01:72, instead of the correct 00:01:12..
Iv'e tested the same codes both sending one to the application screen (useing "put") and the other messes up when i send it online. ex: (put : stream, "PRIVEMSG " + channel_name + message(which would be the time))
I will equipt the codes below just incase you don't know what i mean.
Warning: Code2 will not work without connecting to a server.
Code1 (works)
code: |
var timeRunning : int
var secs, mins, hrs : int := 0
proc TimePlayed
clock (timeRunning)
secs := round ((timeRunning div 1000) - (mins * 60))
mins += round ((secs div 60) - (hrs * 60))
hrs += round (mins div 60)
if hrs < 10 and mins < 10 and secs < 10 then
put "0", hrs, ":0", mins, ":0", secs
elsif hrs < 10 and mins < 10 then
put "0", hrs, ":0", mins, ":", secs
elsif hrs < 10 and secs < 10 then
put "0", hrs, ":", mins, ":0", secs
else
if mins < 10 and secs < 10 then
put hrs, ":0", mins, ":0", secs
elsif mins < 10 then
put hrs, ":0", mins, ":", secs
else
if secs < 10 then
put hrs, ":", mins, ":0", secs
else
put hrs, ":", mins, ":", secs
end if
end if
end if
end TimePlayed
loop
TimePlayed
end loop
|
Code2 (which errors) -- i don't get it
Note that you cannot test this one without connecting to the server, just tell me why if you see an error, that it dosn't work correctly.
code: |
proc UP_TIME
clock (time_running)
secs := round ((time_running div 1000) - (mins * 60))
mins += round ((secs div 60) - (hrs * 60))
hrs += round (mins div 60)
if hrs < 10 and mins < 10 and secs < 10 then
put : stream, "PRIVMSG " + channel_name + " :" + "0", intstr (hrs) + ":0" + intstr (mins) + ":0" + intstr (secs)
put "1"
elsif hrs < 10 and mins < 10 then
put : stream, "PRIVMSG " + channel_name + " :" + "0", intstr (hrs) + ":0" + intstr (mins) + ":" + intstr (secs)
put "2"
elsif hrs < 10 and secs < 10 then
put : stream, "PRIVMSG " + channel_name + " :" + "0", intstr (hrs) + ":" + intstr (mins) + ":0" + intstr (secs)
put "3"
else
if mins < 10 and secs < 10 then
put : stream, "PRIVMSG " + channel_name + " :" + intstr (hrs) + ":0" + intstr (mins) + ":0" + intstr (secs)
put "4"
elsif mins < 10 then
put : stream, "PRIVMSG " + channel_name + " :" + intstr (hrs) + ":0" + intstr (mins) + ":" + intstr (secs)
put "5"
else
if secs < 10 then
put : stream, "PRIVMSG " + channel_name + " :" + intstr (hrs) + ":" + intstr (mins) + ":0" + intstr (secs)
put "6"
else
put : stream, "PRIVMSG " + channel_name + " :" + intstr (hrs) + ":" + intstr (mins) + ":" + intstr (secs)
put "7"
end if
end if
end if
end UP_TIME
|
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
[Gandalf]
|
Posted: Mon Apr 24, 2006 12:37 am Post subject: (No subject) |
|
|
I'm afraid that, as much as I wish I could help you, I can't. You see, it's because you're copying my idea so unequivocally...
All I can say, is that simple is best, and that's definately not the path you're on. Also, another piece of advice that I may share is that it would be far easier if you were to work with either strings or ints throughout the program, not switching half way. |
|
|
|
|
|
TokenHerbz
|
Posted: Mon Apr 24, 2006 3:02 pm Post subject: (No subject) |
|
|
lol gandalf, this is the only part where i switch'd, and make it complicated
and its the only part that dosn't work. and whats unequivocally....
If i remember correctly, you copied me (making bot with turing Muhaha)
I suppose ill try the easy root, and see where that'll lead me. |
|
|
|
|
|
Cervantes
|
Posted: Mon Apr 24, 2006 6:29 pm Post subject: (No subject) |
|
|
One way or another, you guys are all copying cartoon_shark. |
|
|
|
|
|
TokenHerbz
|
Posted: Mon Apr 24, 2006 6:56 pm Post subject: (No subject) |
|
|
Id say hacker_dan, i don't know about a cartoon shark...
its hacker_dans awsome god bot that made me want one too :S
then i try, and mines sucks maga bad, and gandalf made one to show me up..
Good old cervantes, you should join in too...
Its the "new" thing... |
|
|
|
|
|
Cervantes
|
Posted: Mon Apr 24, 2006 7:31 pm Post subject: (No subject) |
|
|
TokenHerbz wrote: Id say hacker_dan, i don't know about a cartoon shark...
No; cartoon_shark was working on a ruby bot in December or January.
TokenHerbz wrote: Good old cervantes, you should join in too...
Its the "new" thing...
Little do you know...
Anyways, you're doing a lot of work to get the time. Isn't there a built-in function that gives you the current time, all nicely formatted? Check the Time module. |
|
|
|
|
|
TokenHerbz
|
Posted: Tue Apr 25, 2006 3:26 pm Post subject: (No subject) |
|
|
of course cervantes, i use that for the time / date commands
I just wanted to try and make my own, i like to know how things work not just use fcn's previously made... its bordom, i suppose, so i just make simple things over complicated
Anyways did you comment to me : "little do you know" mean that you are making one? In which lang?? |
|
|
|
|
|
Cervantes
|
Posted: Tue Apr 25, 2006 5:13 pm Post subject: (No subject) |
|
|
TokenHerbz wrote: Anyways did you comment to me : "little do you know" mean that you are making one? In which lang??
So many questions. No more! Don't make me lock this topic! >_<
;) |
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|