Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,767 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
array index problem #137210
06/20/07 08:01
06/20/07 08:01
Joined: Jun 2007
Posts: 8
H
hammeraxe Offline OP
Newbie
hammeraxe  Offline OP
Newbie
H

Joined: Jun 2007
Posts: 8
hi eveyone!

I have a problem: I've got an array buildings[300] but when it is called with an index bigger than 0 the engine crashes...

here is one example:

function filewr
{var filehandle;
var a;


a=0;
filehandle=file_open_write("buildings.txt");
while(a<=99)
{


file_var_write(filehandle,buildings[0*100+a]);
file_var_write(filehandle,buildings[ 1*100+a]);
file_var_write(filehandle,buildings[ 2*100+a]);
a+=1;
wait(1);
}
file_close (filehandle);
}

Re: array index problem [Re: hammeraxe] #137211
06/20/07 08:15
06/20/07 08:15
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Make sure that you really have the line:
var buildings[300];

and no var or any other object that is named "buildings" too.

This code is working perfectly for me:
Code:

var buildings[300];



function save_array()
{
var fhandle;
var i;

fhandle = file_open_write("save.txt");
i = 0;

while(i < 100)
{
file_var_write(fhandle,buildings[0*100 + i]);
file_var_write(fhandle,buildings[1*100 + i]);
file_var_write(fhandle,buildings[2*100 + i]);

i += 1;
}

file_close(fhandle);

// error("Array saved");
}



Re: array index problem [Re: hammeraxe] #137212
06/20/07 08:16
06/20/07 08:16

A
Anonymous
Unregistered
Anonymous
Unregistered
A



must be the array-declaration (the code seems ok)

var buildings[300]; // global var

Re: array index problem [Re: ] #137213
06/20/07 08:35
06/20/07 08:35
Joined: Jun 2007
Posts: 8
H
hammeraxe Offline OP
Newbie
hammeraxe  Offline OP
Newbie
H

Joined: Jun 2007
Posts: 8
ahhhhhhhhhhhh....

i'm a real idiot...

i had

var buildings(300) not [300]


thanks


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | 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