What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [split] multi-dimensional arrays

[split] multi-dimensional arrays
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [Question] Timer usage
[OFF TOPIC]

quote:
Originally posted by tryxter
But if there's a way to do (or simply simulate) it, it should be explained, don't you think?
Which is clearly explained in the JScript documentation:
quote:
Although JScript does not directly support multi-dimensional arrays, you can store any sort of data inside array elements — including other arrays. So you can get the behavior of multi-dimensional arrays by storing arrays within the elements of another array. For example, the following code builds a multiplication table for the numbers up to 5:
code:
// Change this number for a bigger table
var iMaxNum = 5;
// Loop counters
var i, j;

// New array. Make it iMaxNum + 1 because arrays start
// counting at zero, not 1.
var MultiplicationTable = new Array(iMaxNum + 1);

// Loop for each major number (each row in the table)
for (i = 1; i <= iMaxNum; i++)
{
    // Create the columns in the table
    MultiplicationTable[i] = new Array(iMaxNum + 1);

    // Fill the row with the results of the multiplication
    for (j = 1; j <= iMaxNum; j++)
    {
        MultiplicationTable[i][j] = i * j;
    }
}

window.alert(MultiplicationTable[3][4]); // Displays 12
window.alert(MultiplicationTable[5][2]); // Displays 10
window.alert(MultiplicationTable[1][4]); // Displays 4






Also, when one puts 1 plus 1 (elements of arrays can contain anything, including objects, and arrays are objects) you come automatically to how to make/simulate multidimensional arrays. I'm not sure if every basic thing you can do with objects, etc needs to be explained in 'tips'. It's basic programming...

[/OFF TOPIC]

This post was edited on 01-10-2007 at 07:32 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
01-10-2007 07:24 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread


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