Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
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
3 registered members (TedMar, AndrewAMD, fairtrader), 578 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 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