Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Newbie Questions
by AndrewAMD. 12/04/23 11:14
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (TipmyPip, Quad, alibaba, izorro), 545 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Multi dimensional arrays ? #268522
05/29/09 19:57
05/29/09 19:57
Joined: May 2009
Posts: 11
Romania, Targu Mures
F
F_P_kefas Offline OP
Newbie
F_P_kefas  Offline OP
Newbie
F

Joined: May 2009
Posts: 11
Romania, Targu Mures
I`m a little new on the forum, and I was looking in the existing posts but couldn`t find may answer.

How can you define multi dimensional arrays(if you can)?

I`m using CSript, so:

I want to define an array variable that has "array variables".

I tried:


var door[10];
var door_var[3];
var counter=0;

function main(){
while (counter!=10){
door_var[0]=100;
door_var[1]=200;
door_var[3]=300;
door[counter]=door_var;
counter+=1;
}
}


but door[any_number] is always door_var[0]

Something (i know it sounds a little stupid, but...) is needed:

var door[10][3]; - is needed

can anyone help me?


hello
Re: Multi dimensional arrays ? [Re: F_P_kefas] #268524
05/29/09 20:09
05/29/09 20:09
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
Quad Online
Senior Expert
Quad  Online
Senior Expert

Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
as far as i know you cant have multi dimensional arrays in c-script...(but you can in lite-c)

if you are new, start with lite-c.(since it's the new thing)


3333333333
Re: Multi dimensional arrays ? [Re: Quad] #268525
05/29/09 20:14
05/29/09 20:14
Joined: May 2009
Posts: 11
Romania, Targu Mures
F
F_P_kefas Offline OP
Newbie
F_P_kefas  Offline OP
Newbie
F

Joined: May 2009
Posts: 11
Romania, Targu Mures
Thanks for the answer, but I wrote I was new on the forum.
I was doing CScript 5 years ago but meen while programmed in C++, Java, VisualC...
Now I just need thid for something I started in Cscript.

I`ll try lite-c after I finished this project.

But thanks anyway.


hello
Re: Multi dimensional arrays ? [Re: Quad] #268527
05/29/09 20:19
05/29/09 20:19
Joined: Oct 2005
Posts: 4,771
Bay City, MI
lostclimate Offline
Expert
lostclimate  Offline
Expert

Joined: Oct 2005
Posts: 4,771
Bay City, MI
Originally Posted By: Quadraxas
as far as i know you cant have multi dimensional arrays in c-script...(but you can in lite-c)

if you are new, start with lite-c.(since it's the new thing)


it is too possible in c-script, you just need to have a work around its explained under the variable syntax area in the manual.

Re: Multi dimensional arrays ? [Re: lostclimate] #268537
05/29/09 21:05
05/29/09 21:05
Joined: May 2009
Posts: 11
Romania, Targu Mures
F
F_P_kefas Offline OP
Newbie
F_P_kefas  Offline OP
Newbie
F

Joined: May 2009
Posts: 11
Romania, Targu Mures
Well, I`w found a way for arrays to work as multi dimensional:

var door[10];
var door_var[3];
counter_1=0;
counter_2=0;

...
while(counter_1!=10){
while(counter_2!=3{
door[counter_2]=door_var[counter_1];
counter_2+=1;
}
counter_1+=1;
}

and..so an whit many variable as you want,

but still I didn`t DEFINE a multi dimensional array.


P.S.
where in the manual, pleas? smile


hello
Re: Multi dimensional arrays ? [Re: F_P_kefas] #268558
05/29/09 23:23
05/29/09 23:23
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Deep down on the "Variables" page.

Originally Posted By: from the manual
Multidimensional arrays can be defined by multiplying the index by the array width. Suppose you need an array in two dimensions, like a 10*20 grid of height values. It is defined this way:

var heightmap[200]; // 200 = 10*20
The array value at position (j,i) can then be accessed through:

heightmap[j*20 + i] = 10; // j = 0..9, i = 0..19


LC In lite-C, you can alternatively define (uninitialized) and address multidimensional arrays by using several indices:

var heightmap[10][20];...
heightmap[j][i] = 10; // j = 0..9, i = 0..19



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Multi dimensional arrays ? [Re: EvilSOB] #268638
05/30/09 12:27
05/30/09 12:27
Joined: May 2009
Posts: 11
Romania, Targu Mures
F
F_P_kefas Offline OP
Newbie
F_P_kefas  Offline OP
Newbie
F

Joined: May 2009
Posts: 11
Romania, Targu Mures
Thanks.
Thats cool.

I wil try it.


hello

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1