News:

PlayBASIC2DLL V0.99 Revision I Commercial Edition released! - Convert PlayBASIC programs to super fast Machine Code. 

Main Menu

Question? Need some beginner Help.

Started by Crosis, December 12, 2007, 08:52:28 PM

Previous topic - Next topic

Crosis

I was just wondering can a array have more then 1 dim? like 2 are 3 dim?

kevin

#1
    Dim has a dual purpose in basic in general,

    1)  it's a declaration (declares the variable or arrays name )

    2)  it allocates Array memory..

  You can call dim as many times as you like.   Each time you do, you're destroying the old copy and building a new version.  So it flushes out old information from the array.  If you want to the preserve the contents of an array then you'd use REDIM.




; delcare a 1d array called Myarray()
  Dim MyArray(100)

;store some data in this array
  MyArray(50)=1234567
  print MyArray(50)



; declare a 2D array of the same name.    This will override the previous declaration
Dim MyArray(100,100)

; store some data in this array
  MyArray(50,50)=52 

  print MyArray(50,50)=52 


  Sync
  waitkey
  waitnokey