Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | 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