Confused of some code

Blitz3D Forums/Blitz3D Beginners Area/Confused of some code

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

O.K. waz. I think you've got the basic gist of it, but arrays can be a bit confusing at first.

Try this instead:

Dim cups$(10)

For a = 0 To 9 ; we've only got 10 elements in the array and 0 is a number.
cups$(a) = "rat "+a
Next

Print cups$(5) ; display the contents of element 5 in the array cup$ (actually the 6th element.


The reason why print cup$(a) wouldn't work is because the variable a is undefined once the for..next loop terminated. If you want to display the whole array, try this:

Dim cups$(10)

For a = 0 To 9 ; we've only got 10 elements in the array and 0 is a number.
cups$(a) = "rat "+a
Next

for b=0 to 9
Print cups$(b) ; display the contents of element b in the array cup$.
next


I hope that makes sense.

Have fun.