What are the dynamics of the 'Read' statement?

Miscellaneous Forums/General Discussion/What are the dynamics of the 'Read' statement?

I just found something new (to me) with 'Read' that I never knew about. You can read data and shunt it directly to an array:

Read array_name(index/pointer (whatever it is called))

I never knew this - I have always Read data and then assigned it.

Is there anything else it can do directly? I feel I have missed some sort of coding evolutionary step with this.

An array element is just a variable like any other. Nothing special going on here.

In fact Read/Data is a kindof deprecated old school withered appendix thing.

Every time I've ever used them I've always switched to some other form of storage (file, incbin, direct/function assignment etc).

I grew up using

Read a
arrayname(b)=a

Until now I never knew it could be

Read arrayname(b)

I find it slightly unnerving and unholy.

i would normally do it the same way puki, its usefull for checking if variable a is equal to a pre-defined data end value.

Go back to what your used to...

After all, slight efficiency increases wont really matter...

Yes, but I have been drawn into the satanic way now - it lures me in like a naked sausage.

I want to know more.

What else can you put after the 'Read' statement that is also a direct assignment (blatant shunt)?

Read is still vital!

I use it all the time for small data inits before game starts. (precalculated numbers are awesome for optimizing and read/data is perfect for smaller amounts of data)

I'm using data at that moment for a terrain system that I stole.

I'm just feverishly re-coding it so that it will be my own creation.

Read a
Read b(2)
Read c\d  ;c.d in bMax
Read e[5]


I always thought it was a shame we couldn't write back to Data statements:
Read a
Write b  ; writes back over where 'b' label is.

.a
Data 20
.b
Data 40


Can you Read and shunt directly to a function?

I've used reads into arrays for a long time...
dim map(4,4)
data 1,2,3,4,5
data 2,3,4,5,6
data 3,4,5,6,7
data 4,5,6,7,8
data 5,6,7,8,9

for y=0 to 4
for x=0 to 4
read map(x,y)
next
next


I just invented the concept. It was my idea.

Actually.... Looksy here 5 year old code archive!
http://www.blitzbasic.com/codearcs/codearcs.php?code=169

And ironically puki even commented on it several years ago!

I used Read/Data way back in the 80's, and still use it now, more so for holding default highscore names/scores/settings etc if no specific file is available to read... usually when a user first fires a program up.

I also use it for explaining tilemap examples or array based solutions... Read/Data are really handy little commands to have.

I also have a kickback from Amstrad programming where usually I write something like this:-

Read something
Array[index] = something


Just out of habit! :)

Dabz