Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (M_D), 1,430 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
initializing a huge multidimensional array #386977
11/12/11 02:37
11/12/11 02:37
Joined: Nov 2007
Posts: 50
C
Chaeon Offline OP
Junior Member
Chaeon  Offline OP
Junior Member
C

Joined: Nov 2007
Posts: 50
I have a great big list of numbers which i want to store in an array when my program first starts, so that a variety of functions may read from it later. let's say the array is 10x200.

I don't want to type it in like this.

var name[n] = { value_1, value_2, ... value_n };

I don't think that's neat or efficient, to have 2000 numbers in a huge block at the beginning of my script!

One idea i had were to have them in an external text file, and use a loop to copy each number into my array at the beginning.

Another idea was to do the same with an image file.

What do you think would be the neatest way to do this?

Thanks for your time laugh


I HEART 3DGS
Re: initializing a huge multidimensional array [Re: Chaeon] #386981
11/12/11 03:38
11/12/11 03:38
Joined: Sep 2011
Posts: 13
T
texcoord3 Offline
Newbie
texcoord3  Offline
Newbie
T

Joined: Sep 2011
Posts: 13
yes, reading from a file is a wonderful idea! In fact, that's how objects like 3d models and textures are generally read into memory.

I would use a plain text or compressed text file to read from, not a texture file (unless you want to read in a texture) since texture file will generally have a specific storage format which you might not need. For example if you don't want the trouble of parsing the red, green, blue from a .bmp file then it would just be easier to read from text. Also some formats may be compressed like .tga or .dds so you should be careful with texture/image files when loading.

Re: initializing a huge multidimensional array [Re: texcoord3] #386984
11/12/11 06:01
11/12/11 06:01
Joined: Nov 2007
Posts: 50
C
Chaeon Offline OP
Junior Member
Chaeon  Offline OP
Junior Member
C

Joined: Nov 2007
Posts: 50
okay i'll do it by an ordinary text file then. File_var_read seems totally perfect for this. thank you!


I HEART 3DGS
Re: initializing a huge multidimensional array [Re: Chaeon] #386994
11/12/11 11:43
11/12/11 11:43
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Depending on how you are collecting this information initially,
FILE_LOAD may also be helpful for you too.

If you can get the data into gamestudio ONCE, then you can use FILE_SAVE
to store the entire array to a binary file.
This file can then be FILE_LOADed straight into your array later.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial

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