Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Arrays in AGK2 (READ-DATA)

Author
Message
zxretrosoft
AGK Developer
4
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 10th Mar 2016 11:44 Edited at: 10th Mar 2016 12:16
Hello all,
I have 2-dimensional array.

E.g.
Global Dim a[17,12]

And now I want to manually populate data.

In the documentation of the AGK2 is an example, which is not very convenient.


There is a better way?
When I'll have a big array, so it will be terrible ...

In classic Basic there are DATA-READ commands. There is something in the AGK2? Thanks!
I am sorry for poor English
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Mar 2016 14:13
Where is your data coming from? I guess you do not plan to hard-code a long series of values. Are you generating the numbers in code? Reading them from a file?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
zxretrosoft
AGK Developer
4
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 10th Mar 2016 14:27
Thank you.
No file. Normally manually enter values into the array. Exactly how's example.
I am sorry for poor English
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 10th Mar 2016 16:17
My personal opinion is that you should not hard-code the values in your program. It makes it very hard to modify, and if you have an error after publishing, you have to recompile and deliver the full executable again. I would recommend using a text file to populate your array. You code would then look something like this, simplified...

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
blink0k
AGK Developer
6
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 10th Mar 2016 20:48 Edited at: 10th Mar 2016 20:53
My advice is to take mr vinks advice and use a file. If you insist on using a definition then you could do something like this;


Some things to watch out for;
DO NOT USE DIM Read this http://www.appgamekit.com/documentation/guides/12_array_changes.htm. I didn't and now they call me dim
You need to download and install Version 2.0.18 or it will not work
All arrays begin with index zero. When you define an array, say arr[10], the 10 refers to the LAST element not the number of elements
AGK will reduce the length of your array to the number of elements you define
zxretrosoft
AGK Developer
4
Years of Service
User Offline
Joined: 10th Dec 2014
Location: Prague, Czech Republic
Posted: 11th Mar 2016 06:55
Thank you guys!
blink0k, Yes, this is exactly it. But it does not work in AppGameKit 2.16 in AppGameKit 2.18 everything it's OK.
Thank you.
I am sorry for poor English
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 18th Mar 2016 16:43
Regarding of the good practice of not hard-coding variable values,

I noticed in a lot of games, like Minecraft and Skyrim, the had text files which stores variables along with its variable name, for example



How do we make the program read the values of the variables if they are written like that (variable name with values)?

So far I only put in the values of the variable in text files, and not the variable names.

Is there an easy way to read variable values if they are written like the above?
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 18th Mar 2016 22:55
You'll be needing this drop-in module with tutorial...

http://tutcity.devink.co.uk/agk-parameter-driven-apps/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 19th Mar 2016 03:36
That's really useful, thanks.

By the by, is there any way to do these 'parameters' loading and exporting in DBPro?
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 19th Mar 2016 14:17
The code would essentially be the same. The commands just need converting.
If you have Matrix1 utils I think it contains the old Windows ini file commands too.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
hakimfullmetal
4
Years of Service
User Offline
Joined: 17th Feb 2015
Location:
Posted: 19th Mar 2016 15:47
Alright, thanks, I'll check the Matrix1 utils plugin.

Login to post a reply

Server time is: 2019-11-17 20:00:11
Your offset time is: 2019-11-17 20:00:11