Accessing Array Elements

Posted by Kromlech on Sat 23 Nov 2002 04:10 AM — 2 posts, 11,740 views.

USA #0
Ok, I have a book on Jscript that says "You can read the contents of an array using the same notation you used when assigning walues." I tried to do what it said but I gave up so here is my script.

function NumericTest3 (thename, theoutput, thewildcardsVB)
{
scores = new Array()
scoredisp = "Scores; + scores[0] + "," + scores[1] + "," + scores[2]"
world.send("\" " + scoredisp)
}

When it sends it to the world all it sends is
Scores; + scores[0] +

I want to display the values of the first three elements of the scores array. Does anybody know how to get this to work?



USA #1
Umm.. Well, you have your "" all messed up. "" should be 'only' around literal information (things not stored in a variable). Thus:

scoredisp = "Scores;" + scores[0] + "," + scores[1] + "," + scores[2];

will work, but not the way you had it. ;)