[SOLVED]Understanding array-file structure

For questions about using Classic.

Post » Wed Apr 20, 2011 12:50 pm

Hi everyone!

Short version:
How do I load predefined entries (much of them!) into an array? What format does the file need to be?

Long version:
After being able to create a heap of random stars I now want to give them individual names. Each instance has its private variable "name", awaiting to be filled.

I planned doing this with an array, that in turn I fill from a prepopulated list (textfile for instance). The problem: "Load from file" doesn't work OR does not work the way I though it would.

I have a starnames.ini/txt with the following content:
[code:1l8hgza7]5653 Felis
1947 Eridani
6649 Chitra
7801 Liu Xiu
1954 Andromedae
3504 Fornacis
7245 Felis[/code:1l8hgza7]

After filling the array with this file I print the array into a text-element, which promptly displays: "0". Nothing else.
(Printing into the textfield is done by a loop "for i = 1 to Array.SizeY which loops the following: set text to Array(global('counter'), 1) and global('counter')++)

So obviously I cant simply load a textfile into an array. I filled the array with some entries by hand and then used "save to file" just to see what structure it would have, only to get some unreadable hickup of chars and stuff.

Can someone please help me on this? I found nothing by searching the forum for keywords "array" (which returned an error by the way [you can't search at the moment], probably too much hits), "file array", "load from file" and so on.

Best regards,
Noel
B
3
G
2
Posts: 35
Reputation: 770

Post » Wed Apr 20, 2011 1:20 pm

Try this
http://dl.dropbox.com/u/24325446/tar.zip

(I used "-1" for NumTokens because of some crappy stuff appeared in the end of string, don't know what it was)
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Wed Apr 20, 2011 3:08 pm

Well that works. I do not fully understand what happens in your example, but I managed to port it to my needs and that is all that counts.

Thanks for the great and fast help!
Best regards,
Noel
B
3
G
2
Posts: 35
Reputation: 770


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests