What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Problem with Script - ; required? Where?

Problem with Script - ; required? Where?
Author: Message:
markee
Veteran Member
*****

Avatar

Posts: 1621
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: Problem with Script - ; required? Where?
quote:
Originally posted by matty
blah why not do this

code:
var aWordArray = new Array ('Hello!', 'Hi!', 'Yo', 'Allo', 'Hiya', 'How are you?');
Debug.Trace(aWordArray[Math.round(Math.rand() * aWordArray.length + 1)]);


I think you actually mean this:
code:
var aWordArray = new Array ('Hello!', 'Hi!', 'Yo', 'Allo', 'Hiya', 'How are you?');
Debug.Trace(aWordArray[Math.floor(Math.rand() * aWordArray.length + 1)]);

And you should use Math.floor() rather than Math.round() anyway, this is because the use of rounding means that the first and last variable have only half of the probability of getting chosen as the others do.  And with matty's code anywa, the addition of 1 would have meant that the array elements would have to start from 1 rather than zero.
[Image: markee.png]
08-01-2007 11:45 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Problem with Script - ; required? Where? - by Toneo on 08-01-2007 at 07:22 PM
RE: Problem with Script - ; required? Where? - by Mnjul on 08-01-2007 at 08:02 PM
RE: Problem with Script - ; required? Where? - by matty on 08-01-2007 at 08:10 PM
RE: Problem with Script - ; required? Where? - by markee on 08-01-2007 at 11:45 PM
RE: Problem with Script - ; required? Where? - by Toneo on 08-02-2007 at 08:41 AM
RE: Problem with Script - ; required? Where? - by LifelesS on 08-02-2007 at 12:00 PM
RE: Problem with Script - ; required? Where? - by matty on 08-02-2007 at 12:40 PM
RE: RE: Problem with Script - ; required? Where? - by LifelesS on 08-02-2007 at 01:15 PM
RE: Problem with Script - ; required? Where? - by LifelesS on 08-02-2007 at 12:43 PM
RE: Problem with Script - ; required? Where? - by Ezra on 08-02-2007 at 01:03 PM


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