﻿ 2D pole
• September 19, 2024, 03:57:08 PM
• Welcome, Guest

### News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Pages: [1]

### AuthorTopic: 2D pole  (Read 4571 times)

0 Members and 1 Guest are viewing this topic.

#### Siky

• Lurker
• Karma: 0
• Offline
• Gender:
• Posts: 41
##### 2D pole
« on: May 31, 2007, 06:24:45 PM »

Můžete mi někdo poradit proč mi nechodí to dvoudimenzionální pole array1?

Code: [Select]
`var array1 = new Array();function napln_data(){var temp1;var array2 = new Array();for (var j=0; j<3; j=j+1){  for (var i=0; i<3; i=i+1)  {    array2[i] = 10*i+j;    Game.LOG(array2[i]);  }  temp1.array = array2;  array1[j] = temp1;}}function vypis_data(){var t;var t2;for (var j=0; j<3; j=j+1){  t = array1[j];  for (var i=0; i<3; i=i+1)  {    t2 = t.array;    Game.LOG(t2[i]);  }}`
Po volání:
Code: [Select]
`napln_data();Game.LOG("----------");vypis_data();`
to vypíše:
Code: [Select]
`19:16: 019:16: 1019:16: 2019:16: 119:16: 1119:16: 2119:16: 219:16: 1219:16: 2219:16: ----------19:16: 219:16: 1219:16: 2219:16: 219:16: 1219:16: 2219:16: 219:16: 1219:16: 22`
Mělo by to přeci vypsat ta samá data, ne?
Logged

#### Mnemonic

• WME developer
• Addicted to WME forum
• Karma: 41
• Offline
• Gender:
• Posts: 5683
##### Re: 2D pole
« Reply #1 on: May 31, 2007, 06:55:57 PM »

Protoze array2 je porad tentyz objekt, jenom ho plnis trikrat, takze v nem zustanou ty posledni hodnoty.
Zrejme jsi mel na mysli spis tohle:

Code: [Select]
`function napln_data(){  var temp1;    for (var j=0; j<3; j=j+1)  {    var array2 = new Array();    for (var i=0; i<3; i=i+1)    {      array2[i] = 10*i+j;      Game.LOG(array2[i]);    }    temp1.array = array2;    array1[j] = temp1;  }}`
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum.

#### Siky

• Lurker
• Karma: 0
• Offline
• Gender:
• Posts: 41
##### Re: 2D pole
« Reply #2 on: May 31, 2007, 07:01:33 PM »

Jo, to je přesně ono, to jsem přehlédl. Díky
Logged
Pages: [1]

Page created in 0.025 seconds with 18 queries.