FAQ  •  Register  •  Login

Arrays question

<<

rikokun

Posts: 13

Joined: Mon Apr 18, 2016 9:51 pm

Post Sun Nov 06, 2016 2:55 pm

Arrays question

Hallo.

So i was looking for an answer on the forums but couldn't find it.
How do i change content of an array?
I have game maps in array of course and i want to load different screen layout to the same array i used before.

I know i can do:

dim a(10) as ubyte => {1,2,3,...}

Now how to change it to something else?

In the olden days i used data to fill arrays quickly, dut that doesn't seems to be case anymore ^_^

edit: well i guess i can make a 3D array and instead of loading data into 2D array, simply switch to another layer of 3D array. But i dont know what is better memory-wise. The data needs to be there any way, but i don't know, i just don't like having huuuuge 3D array of all the screens in the game in memory at all times...
Plus i was hoping i could load data to new area from file...
<<

boriel

Site Admin

Posts: 1462

Joined: Wed Nov 01, 2006 6:18 pm

Location: Santa Cruz de Tenerife, Spain

Post Wed Nov 09, 2016 4:22 pm

Re: Arrays question

rikokun wrote:Hallo.
edit: well i guess i can make a 3D array and instead of loading data into 2D array, simply switch to another layer of 3D array. But i dont know what is better memory-wise. The data needs to be there any way, but i don't know, i just don't like having huuuuge 3D array of all the screens in the game in memory at all times...
Plus i was hoping i could load data to new area from file...


I'm not sure I understand your question.
You mean change the ARRAY Shape (dimensions)? Unfortuntely this is not implemented (yet) in ZX BASIC. This are called Dynamic Arrays. They are a bit slower but better under many circumstances.
If your question is not related to this, please tell me so I can help you.
<<

rikokun

Posts: 13

Joined: Mon Apr 18, 2016 9:51 pm

Post Thu Nov 10, 2016 8:18 am

Re: Arrays question

No, i ment something like

Dim a(4)

let a(0-4) = 1, 2, 3, 4, 5

I know you can put the values stright in the array when you declare it, but it would be nice to be able to be able to change its content later

Never mind, i found a way arround it by poking it using defb and reading data straight out of memory :)
<<

britlion

Posts: 764

Joined: Mon Apr 27, 2009 7:26 pm

Location: Slough, Berkshire, UK

Post Wed Mar 15, 2017 3:53 pm

Re: Arrays question

rikokun wrote:No, i ment something like

Dim a(4)

let a(0-4) = 1, 2, 3, 4, 5

I know you can put the values stright in the array when you declare it, but it would be nice to be able to be able to change its content later

Never mind, i found a way arround it by poking it using defb and reading data straight out of memory :)


I'm confused by this question, too. It's an array - of course you can change the contents.

let a(3)=8 - and you've changed the fourth value (remember it starts at 0) to 8...

Return to Help & Support

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest

cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.

phpBB SEO