Server Help

Bot Questions - ArrayList.size() sends multiple times...(help)

BDwinsAlt - Mon Aug 29, 2005 10:33 am
Post subject: ArrayList.size() sends multiple times...(help)
OK i have this !error command that reports errors for my bot. I want to be able to show Total Errors at the bottom this is what happends:

BDwinsAlt> !errorlist
ST 2.3> 08/28/2005 - BDwinsAlt : test
Total Errors: 1

now watch

BDwinsAlt> !errorlist
ST 2.3> 08/28/2005 - BDwinsAlt : test
ST 2.3> 08/28/2005 - BDwinsAlt : test2
Total Errors: 2
Total Errors: 2

If it has two errors, it sends total errors twice.
How do i stop this? My code is:

for (int i = 0; i < log.size(); i++) {
m_botAction.sendPrivateMessage( name, "Total Errors: " + log.size() );
}
Maverick - Mon Aug 29, 2005 10:36 am
Post subject:
Just move the 'sendPrivateMessage()' outside the for() loop or remove the for() loop alltogether.
Bak - Mon Aug 29, 2005 12:27 pm
Post subject:
Code: Show/Hide

m_botAction.sendPrivateMessage( name, "Total Errors: " + log.size() );

for (int i = 0; i < log.size(); i++)
{
   m_botAction.sendPrivateMessage( name, "Error #" + (i + 1) + ": " + log.get(i) );
}


Mave was right.
BDwinsAlt - Mon Aug 29, 2005 2:53 pm
Post subject:
Alright ill try it. Thanks.
BDwinsAlt - Mon Aug 29, 2005 3:05 pm
Post subject:
It worked. Thanks guys. I had it reading from a text file ahaha so it posted it twice anyways. icon_redface.gif I removed the Buffered Reader and now its just an actual log. $$ Thanks guys. You Rock! icon_razz.gif
Cyan~Fire - Mon Aug 29, 2005 4:43 pm
Post subject:
Ah hah! So Java can't fix all programmer's errors by itself!
BDwinsAlt - Mon Aug 29, 2005 6:00 pm
Post subject:
It's free, and so advanced icon_razz.gif What do you expect?
D1st0rt - Mon Aug 29, 2005 6:31 pm
Post subject:
I don't know of anything that actually fixes logical errors with any degree of success, cyan icon_wink.gif
BDwinsAlt - Mon Aug 29, 2005 6:36 pm
Post subject:
sa_tongue.gif I love you.
D1st0rt - Mon Aug 29, 2005 6:38 pm
Post subject:
(he's kidding of course)

Cyan, you should make a program that's actually just you going through correcting errors and writing the rest of the code. I would use that program like every day.
BDwinsAlt - Mon Aug 29, 2005 6:44 pm
Post subject:
I never said i was kidding icon_lol.gif
lol just playing. But i really look up to you. Your cool in my eyes.
D1st0rt - Mon Aug 29, 2005 6:44 pm
Post subject:
I meant cyan was kidding, and thank you biggrin.gif
Cyan~Fire - Tue Aug 30, 2005 3:57 pm
Post subject:
Lol. What would it say if you used Java? "Get a real language, retard."
BDwinsAlt - Tue Aug 30, 2005 6:43 pm
Post subject:
How is any of it real? Its all virtual anyways sa_tongue.gif
SamHughes - Tue Aug 30, 2005 8:05 pm
Post subject:
This reminds me of one of my more favorite quotes.

Charles Babbage wrote:
On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.

BDwinsAlt - Tue Aug 30, 2005 8:55 pm
Post subject:
I like marshmallows icon_confused.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group